Regexdrill

Level 2: Groups and alternation Exercise 24 of 70 Free

Backreference: a doubled letter

A regex exercise from Regexdrill. Solve it with a pattern box with live highlighting in your browser, checked against hidden test strings, and it is checked the moment you submit.

The task

A match anywhere counts. Match lines that contain the same lowercase letter twice in a row, like the ll in hello. Only letters count, and matching is case sensitive, so aA and 11 do not count.

What this exercise teaches

([a-z])\1 captures a letter and demands the identical letter next. [a-z]{2} would accept any two letters, and (\w)\1 would also accept doubled digits and underscores.

A hint if you get stuck

Capture one lowercase letter and follow it with \1, the backreference to that capture.

Try it now, free, no account needed

Every exercise on Regexdrill is free to try. Open it on the practice page, solve it, and get instant feedback with a hint. A free account adds the worked solution; Pro adds timed mode and the certificate.

Open this exercise

More exercises in Groups and alternation