Match if >= 2 of the words are found, in any order and case
我该怎么做呢?几个小时后,我厌倦了阅读正则表达式。谢谢!
绝地无双
浏览 103回答 2
2回答
慕田峪9158850
你可以这样做:re, _ := regexp.Compile(`\b(?i:jack|jill|john)\b`)ma := re.FindAllString("Jill is friends with John. But Jack doesn't know.", -1)if len(ma) < 2 //...then there aren't enough matches.或者,(\b(?i:jack|jill|john)\b.*){2,}做你想做的,我想。