0

I am trying to design a regex where the first 8 letters are the same.

Examples:

oooooooo34reefe
aaaaaaaafsfdew4regr4
llllllllsftgerf
qqqqqqqqdhiocdnsfncdops

Thanks for your help.

Nikolas Charalambidis
  • 40,893
  • 16
  • 117
  • 183
Agoose Banwatti
  • 410
  • 2
  • 13
  • 1
    Possible duplicate of [Regular Expression to check for repeating characters](https://stackoverflow.com/questions/12258622/regular-expression-to-check-for-repeating-characters) – CertainPerformance May 16 '19 at 07:54
  • and https://stackoverflow.com/questions/1240504/regular-expression-to-match-string-starting-with-stop (anchor to beginning with `^`) – CertainPerformance May 16 '19 at 07:55

1 Answers1

2

Try this Regex:

^(.)\1{7}
  • ^ is the start of the line. You would get more matches otherwise.
  • (.) matches a character and captures it (in case the ^ is used, it becomes the first character)
  • \1 express that the captured character must occur there
  • {7} ... seven times (since the first one has been already matched, 7 out of 8 left)
Nikolas Charalambidis
  • 40,893
  • 16
  • 117
  • 183