Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
我正在尝试匹配具有所有正确字母但可能有重复字母的单词。
像 ddddaaammmnn
[a-z]*([damn])\\1{1,}[a-z]*不起作用,因为whhaaaat bananas ddaammn同时捕获whaaat和ddaammmn。
[a-z]*([damn])\\1{1,}[a-z]*
whhaaaat bananas ddaammn
whaaat
ddaammmn
[a-z]*([d])\\1{1,}[a-z]*将捕获所有 d 的重复。
[a-z]*([d])\\1{1,}[a-z]*
如何告诉正则表达式以可能重复的特定顺序检查模式或字母?
w+h+a+t+
匹配what,wwwhaaaattt以及所有其他变体,what只要字母顺序正确。
what
wwwhaaaattt