John Connor
John Connor

Reputation: 93

How can I match a word containing every vowel at least once?

How can I match a word containing every vowel at least once?

Upvotes: 5

Views: 1082

Answers (2)

tchrist
tchrist

Reputation: 80423

It depends what you mean by a “vowel” — and for that matter, what you mean by “word”, too — but the normal way would be something like this:

(?xsi)
(?= .* a)
(?= .* e)
(?= .* i)
(?= .* o)
(?= .* u)
(?= .* y)

But you don’t want to do it that way. You want to put the logical conjunction in the programming language proper, not the regex, which leads to something like this (disregarding casing issues):

/a/ && /e/ && /i/ && /o/ && /u/ && /y/

What’s a Vowel?

Note that the entire “vowel” issue is pretty ridiculous, because any continuant can act like a vowel, even if it doesn’t look like one. That means that some letters that don’t look like vowels, are. Plus sometimes letters look like vowels but aren’t.

  1. For example, the s is psst, the second l in little, the r in acre, and the n in nth are all acting as vowels. Plus there’s the famous word cwm, from Welsh, where w is a vowel.

  2. Furthermore, the e in Mike is not acting as a vowel, whereas the i there is a diphthong (two vowels fused).

  3. Also, while the y in sky is a vowel, the y in yellow is not a vowel.

  4. You’ll have to figure out how many vowels you think there are in words like lie or speak, or even queue.

  5. Finally, if you have diacritics, you have to decide whether to count them as separate. Are e, é, è, and ê just one vowel, or four?

Upvotes: 4

user557597
user557597

Reputation:

How about this

\s* (?= \S* a)  (?= \S* e)  (?= \S* i)  (?= \S* o)  (?= \S* u)  (?= \S* y) (\S*)

Upvotes: 2

Related Questions