Search code examples
c#regexc#-4.0

What is the meaning of the Regular Expression ^(.)\1+$


Since I am new of regular expression I well versed with Regex.

Can someone please help with the meaning of this Regex?

^(.)\1+$


Solution

  • ^(.)\1+$ is a clever regular expression that matches to any full line that has two or more letters all of which are identical. E.g.:

    • aaa
    • BBBBBBB

    See comments for explanation of what each part of the regular expression does.