1

Trying to find a regex that matches to a String with only one type of character:

Example: "aaaaaa" or "a"

What expression would do this?

sir_thursday
  • 5,270
  • 12
  • 64
  • 118
  • possible duplicate of [Regular expression to match any character being repeated more than 10 times](http://stackoverflow.com/questions/1660694/regular-expression-to-match-any-character-being-repeated-more-than-10-times) – senshin Nov 16 '14 at 00:19

1 Answers1

2

Using capturing group and backreference:

/^(.)\1*$/

According to the regular expression engine you're using you may need to replace \1 with $.

falsetru
  • 357,413
  • 63
  • 732
  • 636