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.
这是我的正则表达式:"(?<=^|\\s)([a-z])\\1{3,}(?=\\s|$)"。
"(?<=^|\\s)([a-z])\\1{3,}(?=\\s|$)"
我正在尝试匹配具有连续重复字符 > 2 的单词。
所以wwhhaaaat bananas ffffuuuuuu this is a test应该抓住wwhhaaaatand ffffuuuuuu。
wwhhaaaat bananas ffffuuuuuu this is a test
wwhhaaaat
ffffuuuuuu
当我在 java 中运行这个正则表达式时,它没有捕获任何东西。当我运行([a-z])\\1{3,}它时,它只捕获重复的字符。所以我弄乱了部分以匹配包含字符的单词。
([a-z])\\1{3,}
我该如何解决?
尝试
Matcher m = Pattern.compile("[a-z]*([a-z])\\1{3,}[a-z]*").matcher("So wwhhaaaat bananas ffffuuuuuu this is a test"); while(m.find()) { System.out.println(m.group()); }
印刷
wwhhaaaat ffffuuuuuu