I missing something very basic here.
I want to match all instances of, for instance, throw 'some string' or throw "error here".
p = re.compile(b'throw ["|\'](?P<err>).*["|\']')
This seems to work fine for matching. But, for instance, I want to replace throw 'some string' with, for instance, throw new Error('some string').
My attempt at this:
p.sub(rb"throw new Error('\g<err>')", b'throw \'foobar\'')
Always results in:
b"throw new Error('')"
I have found the match but replaced err with an empty string.