Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import re
- original = r'1234'
- substitution = r'\1$'
- myre = re.compile('34')
- # ^^^ lines i cannot change
- # re.error: invalid group reference 1 at position 1
- print(myre.sub(substitution, original))
- # result: 12\1\$
- print(myre.sub(re.escape(substitution), original))
- # desired result: 12\1$
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement