Reputation: 81
I would like to know how to match words (using javascript version of regex) that contain 2 or more 2 letter sequences of vowels (e.g. visionproof, steamier, preequip).
I'm learning regex at the moments and this is what I have so far (which only matches words containing 2 letter sequence of vowels) and also where I'm stuck at:
Upvotes: 3
Views: 4218
Reputation: 7833
Below regex can be used for getting 2 or more sequences of 2 consecutive vowels
(\w*[aeiou]{2}\w*){2,}
{2} for 2 consecutive vowels and {2,} for 2 or more sequences
Upvotes: 0
Reputation: 658
I use http://regex101.com whenever I want to test out different regular expressions. Here is one I came up with that I believe does what you're looking for.
var text = "visionproof vision proof threevowelswouldworktoo queued",
regex = /\w*[aeiou]{2}\w*[aeiou]{2}\w*/ig;
console.log(text.match(regex));
\w matches word characters. So, this matches 0 or more word characters followed by 2 vowels, followed by 0 or more word characters, followed by 2 vowels, followed by 0 or more word characters. My example is here.
Upvotes: 4
Reputation: 62566
{2,}
(?:[aeiou]{2,})
part - twice, because you want to catche this more than one time/(\w*(?:[aeiou]{2,})\w*(?:[aeiou]{2,})\w*)/g
re = /(\w*(?:[aeiou]{2,})\w*(?:[aeiou]{2,})\w*)/g
str = 'words that contains 2 or more letters sequesnces and some triiiiple visionproof, steamier, preequip'
console.log(str.match(re))
Here is a link to regex101:
https://regex101.com/r/OtsdRA/2
If you want the word
sssiiiisss
not to match (because you don't have two separate blocks of vowels) you should use\w+
between the two vowels blocks:/(\w*(?:[aeiou]{2})\w+(?:[aeiou]{2})\w*)/g
Upvotes: 1
Reputation: 67968
\b\w*[aeiou]{2}\w*[aeiou]{2}\w*\b
Try this.See demo.
https://regex101.com/r/Ph7a0P/3
Upvotes: 1