Match (and capture with parens) the first character, then match consecutive repeats of whatever character you captured. This is called a backreference, and used to match repeated things. Check out perlre and search for "backreference" for more info.
Update: A backref can also match more than one character. You can match the strings "ABCABC" "ABBABB", "CBCB", "DD" with the following regex:
/([ABCD]+)\1/
blokhead
In reply to Re: regular expressions - finding repeats
by blokhead
in thread regular expressions - finding repeats
by glwtta
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |