So, I've got this regex I would like to compile:
(?<!\\)(?:(')|")(?(1)(\\'|[^'\r])+?'|(\\"|[^\r"])+?")
It works fine. But because there are ' and " signs, I need to escape them. So I do:
re.compile('''(?<!\\)(?:(')|")(?(1)(\\'|[^'\r])+?'|(\\"|[^\r"])+?")''')
Which give me the 'unbalanced parenthesis' error. I also tried:
re.compile('(?<!\\)(?:(\')|")(?(1)(\\\'|[^\'\r])+?\'|(\\"|[^\r"])+?")')
Are all those backslashes confusing it, somehow? It's hard enough to understand without having to add more backslashes to escape the backslashes...