重复词的正则表达式 [英] Regular Expression For Duplicate Words
本文介绍了重复词的正则表达式的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我是一个正则表达式新手,我不太明白如何编写一个匹配"正则表达式的正则表达式.任何重复的连续单词,例如:
I'm a regular expression newbie, and I can't quite figure out how to write a single regular expression that would "match" any duplicate consecutive words such as:
春天的巴黎.
不是那个是相关的.
你笑什么?我的正则表达式有那么糟糕吗??
Why are you laughing? Are my my regular expressions THAT bad??
是否有一个正则表达式可以匹配上面所有的粗体字符串?
Is there a single regular expression that will match ALL of the bold strings above?
推荐答案
试试这个正则表达式:
(w+)s+1
这里的 是一个词边界,
1
引用了第一组的捕获匹配.
Here is a word boundary and
1
references the captured match of the first group.
这篇关于重复词的正则表达式的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文