human
Is there a way to refer to the entire matched expression in re.sub without the use of a group?
assistant
Here is some code to place '\' infront of each non-letter char in string `line`

print(re.sub('[_%^$]', '\\\\\\g<0>', line))

#Warning: this code generation is experimental. Please inspect the code for any bugs before executing.