Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Regular expression for 3 different vowels in succession

Tags:

regex

I am trying to write a regular expression that matches 3 or more different vowels in a row. I understand to write a regular expression search 3 identical vowels.

/([aeuioy])\\1{2,}/

But, about 3 different... any thoughts..

Please help me to solve this problem! Actually no thoughts in my head.

like image 481
Mikhail Avatar asked Sep 27 '14 17:09

Mikhail


2 Answers

Look for 3 consecutive vowels. Capture the first in a group. After the first, check if it's not #1 again with a Negative Lookahead. Passing that test, capture the next character. Then use two Negative Lookahead's, one to check if it's not #1 and the other if it's not #2.

The latter step can be OR'ed into a single lookahead.

(?=[aeouiy]{3})(.)(?!\1)(.)(?!\1|\2).

You don't need any test for the last character. The first Lookahead ensures it's one of aeouiy; the third, negative, lookahead ensures it's not character #1 or character #2.

like image 191
Jongware Avatar answered Oct 04 '22 02:10

Jongware


Not that it's necessarily the most practical option, but this is the only one so far that is an "actual" regular expression:

(iea|oea|uea|yea|eia|oia|uia|yia|eoa|ioa|uoa|yoa|eua|iua|oua|yua|eya|iya|oya|uya|iae|oae|uae|yae|aie|oie|uie|yie|aoe|ioe|uoe|yoe|aue|iue|oue|yue|aye|iye|oye|uye|eai|oai|uai|yai|aei|oei|uei|yei|aoi|eoi|uoi|yoi|aui|eui|oui|yui|ayi|eyi|oyi|uyi|eao|iao|uao|yao|aeo|ieo|ueo|yeo|aio|eio|uio|yio|auo|euo|iuo|yuo|ayo|eyo|iyo|uyo|eau|iau|oau|yau|aeu|ieu|oeu|yeu|aiu|eiu|oiu|yiu|aou|eou|iou|you|ayu|eyu|iyu|oyu|eay|iay|oay|uay|aey|iey|oey|uey|aiy|eiy|oiy|uiy|aoy|eoy|ioy|uoy|auy|euy|iuy|ouy)
like image 44
Simon Broadhead Avatar answered Oct 04 '22 02:10

Simon Broadhead