Regex: How to combine words without consecutive vowels?

I am really new to regex, and I managed to find a regex that could compare well with this, but I'm not sure how to combine words without it.

I have a .txt file with words like

sheep
fleece
eggs
meat
potato

I want to make a regular expression that matches words in which vowels are not repeated sequentially, so it will return eggs meat potato.

I am not very good at regular expression, and I could not find anything about how to do this on the Internet, so it would be great if someone with a lot of experience could help me. Thank!

I am using python and testing my regex https://regex101.com .

Thank!

EDIT: . .

+4
2

, , meat, fleece, , .

:

>>> [w for w in open('file.txt') if not re.search(r'([aeiou])\1', w)]
['eggs\n', 'meat\n', 'potato\n']

[aeiou] ( y, ). ([aeiou])\1 , . , not re.search(r'([aeiou])\1', w) w, .

meat, , , :

>>> [w for w in open('file.txt') if not re.search(r'[aeiou]{2}', w)]
['eggs\n', 'potato\n']
+8

@ John1024

"\ * ( {2} | {2} | { 2} | { 2} | {2})\ *" IG

+1

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


All Articles