Regex regex

I am trying to match a word that has 2 vowels (not necessarily sequentially), but the regular expression that I have chosen either does not match any or is not enough. This is the last iteration (dart).

  final vowelRegex = new RegExp(r'[aeiouy]{2}');

Here is an approximate collapsible sentence, which should coincide, one, shoulder, them, etc. This is only a coincidence of the shoulder and them. I understand why, because I defined this expression. How can I define an expression to match on 2 vowels, regardless of position in the word?

  one shoulder their the which over

An expression needs to be tested with only one word, so hopefully this will simplify the situation.

+4
source share
4 answers

Both of the previous two answers are incorrect.

(\S*[aeiouy]\S*){2} , (proof).

\S*[aeiouy]\S*[aeiouy]\S* (proof).


:

\b([^\Waeiou]*[aeiou]){2}\w*\b

, ( , ), , \2.

(\s|^)(([^\Waeiou]*[aeiou]){2}\w*)(\s|$)
+2

:

new RegExp(r'(\w*[aeiouy]\w*){2}');
+3

:

\S*[aeiouy]\S*[aeiouy]\S*

  • \S* ( [^\r\n\t\f ])
  • * Quantifier -
  • [aeiou] , [aeiou]

: one shoulder their the which over

: one shoulder their over

+2

:

\b(?:\w*[aeiouy]+\w*){2,}\b

:

\b            : word boundary
  (?:         : start non-capture group
    \w*       : 0 or more word characters
    [aeiouy]+ : 1 or more vowels 
    \w*       : 0 or more word characters
  ){2,}       : end group repeated at least twice
\b            : word boundary
+2

Source: https://habr.com/ru/post/1665687/


All Articles