我已经经历已经过去了: 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等。
任何人都可以帮我解决这个问题吗?
重复的字符必须相邻吗? – Bathsheba
尝试'((。)\ 2 +)*'。 – Njol
你的意思是说每个角色都应该重复吧..? – TheLostMind