【发布时间】:2014-01-23 08:16:56
【问题描述】:
我已经经历过: Regex to match four repeated letters in a string using a Java pattern 和 Regular expression to match any character being repeated more than 10 times
但在我的情况下它们没有用。如果我只想检查字符串是否包含重复字符(如 1111、abccccd、12aaaa3b 等),它们很好。我想要检查字符串是否完全由重复字符组成,即 aabb111、1111222、11222aaa 等。
谁能帮我解决这个问题?
【问题讨论】:
-
重复的字符一定要相邻吗?
-
你的意思是说每个字符都应该重复正确..?
-
是的.. 字符串应该只包含重复的字符。因此,与正则表达式模式相比,像 111222az 这样的字符串不应返回 true