Correct syntax for pathological re.search()

Michael F. Stemper michael.stemper at gmail.com
Mon Oct 7 09:35:32 EDT 2024


I'm trying to discard lines that include the string "\sout{" (which is TeX, for
those who are curious. I have tried:
   if not re.search("\sout{", line):
   if not re.search("\sout\{", line):
   if not re.search("\\sout{", line):
   if not re.search("\\sout\{", line):

But the lines with that string keep coming through. What is the right syntax to
properly escape the backslash and the left curly bracket?

-- 
Michael F. Stemper
No animals were harmed in the composition of this message.


More information about the Python-list mailing list