Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import re
- input = "aaAaaBBaBBbbb"
- replace = r"\1_mysub_"
- n = 3
- output = re.sub(r"^(.*?((?<=\w)[A-Z].*?){%s})(?<=\w)[A-Z]" % (n - 1), replace, input)
- print (output)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement