While writing a program to detect repeating patterns in binary I came across a weird instance where a regex does not seem to properly match in python.
The regex is ran as followed:
pattern = re.compile("^0b(1*)(0*)(\1\2)*(\1)?$")
result = pattern.match("0b101")
What I would expect to see is the following matching groups:
- 1: '1'
- 2: '0'
- 3: empty
- 4: '1'
But instead I get no match at all. According to the website regex101 the match should be as expected, but python seems to disagree.
Is there a difference between interpreters in python and the website or just some small mistake I'm missing?