javascript - Regex - Match words that contain 2 or more 2 letter sequences of vowels - Stack Overflow

I would like to know how to match words (using javascript version of regex) that contain 2 or more 2 le

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:

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:

Share Improve this question edited Jan 3, 2017 at 22:13 melpomene 85.9k8 gold badges95 silver badges154 bronze badges asked Jan 3, 2017 at 21:55 Danwen HuangDanwen Huang 811 silver badge7 bronze badges 1
  • 2 Just use /\b(?:\w*?[aeiou]{2}){2}\w*\b/g. – Wiktor Stribiżew Commented Jan 3, 2017 at 22:03
Add a ment  | 

4 Answers 4

Reset to default 4

I use http://regex101. 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.

\b\w*[aeiou]{2}\w*[aeiou]{2}\w*\b

Try this.See demo.

https://regex101./r/Ph7a0P/3

  1. You will need to group the entire word
  2. You probably want to make sure not to catch the vowels group.
  3. You want minimum of 2 letters, so you want {2,}
  4. You will need the (?:[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./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

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

发布者:admin,转转请注明出处:http://www.yc00.com/questions/1744352003a4570033.html

相关推荐

发表回复

评论列表(0条)

  • 暂无评论

联系我们

400-800-8888

在线咨询: QQ交谈

邮件:admin@example.com

工作时间:周一至周五,9:30-18:30,节假日休息

关注微信