Unix regular expression begginers question

45 views Asked by At

I'm starting the study of regular expressions and I've been wondering how can I build and test the regular expression in UNIX notation for all vowel strings that contain the substring "ai" or "ui".

would it simply be something like: (ai|ui) ? How could I test it?

1

There are 1 answers

3
Arkadiusz Drabczyk On

IIUC, you want something like '^[aeiou]*?(ai|ui)[aeiou]*$'. Examples:

$ echo aaauiaa | grep -E '^[aeiou]*?(ai|ui)[aeiou]*$'
aaauiaa
$ echo aaaaiaa | grep -E '^[aeiou]*?(ai|ui)[aeiou]*$'
aaaaiaa