I am trying to learn regex and one of the exercise I am trying to solve is as follows:
I have a string:
"london new york"
that I am trying match with regex.
and pattern is like this:
r"(..o(.)).+(\2)*"
Result is ndon new york
.
As far as I understand, (\2) matches n
but what matches ew york
?
Also what does *
in (\2)*
do? Does it try to match n
or special character .
?