Few days ago I was asked to do some regex. The task was to write a regular expression that can match words that are repeated two or more times without a space. An example of the problem is:
This is a samplesample problem and onlyonly the words thatthat
are repeate
d should bebebe matched.
Some of my friends thought that this is impossible to do with regex, so it was
more a challenge to me.
I came up with a very simple solution, the regex code is very short and does exactly what it should do.
([a-z]+)\1+