For example the desired Regex would successfully match "areriroru" but wouldn't match "sadwdij" which contains just two of the vowels.
Asked
Active
Viewed 1,499 times
-4
-
5Please post the expressions you have tried so far and explain what you have problems with. This is not McRegex where you just order an expression. – Felix Kling Mar 31 '13 at 23:35
-
I am a complete beginner with Regex to the point where I wouldn't even know where to start :P – Geesh_SO Mar 31 '13 at 23:36
-
With that I can help you with: http://www.regular-expressions.info/tutorial.html. Have a look at *lookaheads*. Whenever a string should contain something somewhere, lookeheads are the way to go. – Felix Kling Mar 31 '13 at 23:36
-
Thanks, but it's not really help just telling me I can learn Regex ;) Cheers for your time anyway :) – Geesh_SO Mar 31 '13 at 23:40
-
@Geesh_SO - `.*a.*e.*i.*o.*u.*` – vidit Mar 31 '13 at 23:41
-
possible duplicate of [How can I match a word containing every vowel at least once?](http://stackoverflow.com/questions/10324115/how-can-i-match-a-word-containing-every-vowel-at-least-once) – Felix Kling Mar 31 '13 at 23:43
2 Answers
2
In C#, you can use lookahead assertions for each vowel before matching the string with .*
:
(?=.*a)(?=.*e)(?=.*i)(?=.*o)(?=.*u).*
If you don't care about the case of your vowels, you could use this:
(?=.*[Aa])(?=.*[Ee])(?=.*[Ii])(?=.*[Oo])(?=.*[Uu]).*

Sam Harwell
- 97,721
- 20
- 209
- 280
1
One possibility is enumerating all the permutations of the vowels. Here are the first 24 of 120 total (all the ones where a
is the first vowel). Note that this forms one long expression, but I split it into lines here for clarity.
a.*e.*i.*o.*u
|a.*e.*i.*u.*o
|a.*e.*o.*i.*u
|a.*e.*o.*u.*i
|a.*e.*u.*i.*o
|a.*e.*u.*o.*i
|a.*i.*e.*o.*u
|a.*i.*e.*u.*o
|a.*i.*o.*e.*u
|a.*i.*o.*u.*e
|a.*i.*u.*e.*o
|a.*i.*u.*o.*e
|a.*o.*e.*i.*u
|a.*o.*e.*u.*i
|a.*o.*i.*e.*u
|a.*o.*i.*u.*e
|a.*o.*u.*e.*i
|a.*o.*u.*i.*e
|a.*u.*e.*i.*o
|a.*u.*e.*o.*i
|a.*u.*i.*e.*o
|a.*u.*i.*o.*e
|a.*u.*o.*e.*i
|a.*u.*o.*i.*e

Sam Harwell
- 97,721
- 20
- 209
- 280