Я использую PHP 7.4, а также PHP 8.2, и у меня есть регулярное выражение, которое я использую в PHP для сопоставления слов (имен). Честно говоря, я едва узнаю этого созданного мной монстра регулярных выражений. Таким образом, этот вопрос требует помощи в его выяснении. По сути это следующее:
Код: Выделить всё
$is_word = preg_match('/^(?![aeiou]{3,})(?:\D(?![^aeiou]{4,}[aeiou]*)(?![aeiou]{4,})){3,}$/i', $name);
Код: Выделить всё
TRUE
Код: Выделить всё
FALSE
But today it returned
Код: Выделить всё
FALSE
- Li
- Drantch
- Nartinez
- Drantch
- Dratch
- Xtmnprwq
- Yelendez
- Boldberg
- Yelenovich
- Allash
- Mohamed
- Li
Код: Выделить всё
{x,x}
Код: Выделить всё
{5,}
Код: Выделить всё
$is_word = preg_match('/^(?![aeiou]{3,})(?:\D(?![^aeiou]{5,}[aeiou]*)(?![aeiou]{4,})){3,}$/i', $name);
How can this regex be tweaked to properly match all names? If not all names, how can it be adjusted to properly match “Drantch” and other obvious names other that “Li.”
Note that, “Xtmnprwq” is a fake test name so I can test negatives as well as positives.
Источник: https://stackoverflow.com/questions/781 ... quantifier