我有一个文字,让我们说:
Ich gehe auf die Donau und mache eine tolleSchifffahrtwährendichNussschalen esse.
所以现在,我想要找到包含3个相同连续字母的所有单词.在我的情况下,这将是:
Schifffahrt
和
Nussschale
我在RegEx方面没有很多经验,所以我非常感谢帮助.我为你打开了一个regex101页面.
非常感谢你.(对于那些想要知道为什么我需要一些奇怪的东西的人:有些原因我喜欢这个带有3个相同字母的单词,因为它们很少见.所以我想我编写一个机器人,它要求网站,阅读内容,并保存和输出所有找到的带有3个相同字母的单词.很好,不是吗?:))
你可以使用这个正则表达式:
\b\w*(\w)\1\1\w*
Run Code Online (Sandbox Code Playgroud)
RegEx分手:
\b # word boundary
\w* # match 0 more word chars
\w # match a word char and capture it as group #1
\1\1 # match 2 more instances of group #1
\w* # match 0 more word chars
Run Code Online (Sandbox Code Playgroud)