find words that matches the 3 consecutive vowels Regex

Question:

text = "Life is beautiful"
pattern = r"[aeiou]{3,}"
result = re.findall(pattern, text)
print(result)

desired result:
['beautiful']

the output I get:
['eau']

I have tried googling and etc….I found multiple answers but none of them worked!!
I am new to regex so maybe I am having issues but I am not sure how to get this to out

I have tried using r"b[abcde]{3,}b" still nothing SO please help!!

Asked By: Prab

||

Answers:

Your regex only captures the 3 consecutive vowels, so you need to expand it to capture the rest of the word. This can be done by looking for a sequence of letters between two word breaks and using a positive lookahead for 3 consecutive vowels within the sequence. For example:

import re

text = "Life is beautiful"
pattern = r"b(?=[a-z]*[aeiou]{3})[a-z]+b"
result = re.findall(pattern, text, re.I)
print(result)

Output:

['beautiful']
Answered By: Nick

A little improvement on the former solution would be using w instead a-z as the character classes (This will match lower and uppercase letters)

b[w]+[aeiou]{3,}[w]+b

Cheers!

Answered By: gzoanetti
pattern=r"bw*[aeiou]{3,}w*b"

w* For any alpha Alphanumerics that "could" exist before and after the vowels

Answered By: Mustafa Aliraqi

I know it’s a late reply but just wanted to share this for whoever searches this up!

Answer:
pattern = r"b[a-zA-Z][aeiou]{3,}[a-z]b" OR experimenting with [w]* instead of [a-zA-Z]

change the first match from [a-z] to [a-zA-Z]

Answered By: Zac
Categories: questions Tags: , , ,
Answers are sorted by their score. The answer accepted by the question owner as the best is marked with
at the top-right corner.