Can you please explain these pattern for me? pattern = r"(.+) \1" and pattern = r"(.+) \2"
when i use the following script, there is no problem:
import re
pattern = r"(.+) \1"
match = re.match(pattern, "word word")
if match:
print ("Match 1")
but when i change the pattern to r"(.+) \2" it rise an error. please explain exactly what is this pattern mean.
import re
pattern = r"(.+) \2"
match = re.match(pattern, "egg egg egg")
if match:
print ("Match 1")