I would like it to match:
aaaaaa
bb
c
but not:
aaabaaa
cd
...
I would like it to match:
aaaaaa
bb
c
but not:
aaabaaa
cd
...
Using back references:
(.)(\1)*
Read: match any character followed by that same character 0 or more times.
Depending on the regexp engine and your needs, you might want to anchor the regex to only match the whole string, not substrings.
Assuming the regex engine supports back-references,
^(.)\1*$
In Java it would be
theString.matches("(.)\\1*")
Just for contributing to this question, you can use the BackRefence:
(\w+)\s+\1
It checks repeated words separated by whitespace.