I am trying to write a regular expression that will detect a word that is repeated twice, e.g., greatgreat or appleapple. I could not find any way to do this, after hours of trying I am posting it here to see if anyone can help.
I am trying to write a regular expression that will detect a word that
Share
Try this (example on RegExr):
If you want to make sure that the whole sting is a doubled word add anchors:
For more information see the docs – “Round brackets for grouping and backreferences”.