0

I have a csv file where a column is filled with regex expressions.

I want to pass them into re.sub(expression, '', text) for later, but I need the string literal r'expression' rather than the string 'expression'.

Any way to do this?

Thanks

Ed Z
  • 21
  • 3
  • https://stackoverflow.com/a/53140190/2864250 – dubbbdan Feb 22 '19 at 20:16
  • Show an example of a few lines of csv file, read them in, and demonstrate what isn't working for you when using `re.sub`. `r'expression'` is a Python language tool to generate literal strings in code and isn't what you want if reading strings from a file. – Mark Tolonen Feb 24 '19 at 08:59

1 Answers1

-1

If I understand well, you might want to combine double and single quotes:

rext = 'expression'
final_exp = "r'" + rext

print(final_exp)
nocibambi
  • 2,065
  • 1
  • 16
  • 22