If I have several different regular expressions and I want to do nested regular expression like this
r1 = re.compile(r'SO ON')
r2 = re.compile(r'WHATEVER AND (%s)*' % r1.pattern)
r3 = re.compile(r'WHATEVER AND (%s) (%s)' % (r1.pattern, 'r2.pattern'))
Now r3 works. But what if I want to do something like this
r4 = re.compile(r'(r1)(r2)(r1)(r2)(r2)' % (r1.pattern, 'r2.'pattern'))
##NOT VALID CODE, JUST FOR EXPLANATION
I reminded of using group capturing but they only match the exact same thing from where first group where it makes the match, not the pattern. Thanks