Path: ...!feeds.phibee-telecom.net!3.eu.feeder.erje.net!feeder.erje.net!eternal-september.org!feeder3.eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail From: "Michael F. Stemper" Newsgroups: comp.lang.python Subject: Correct syntax for pathological re.search() Date: Mon, 7 Oct 2024 08:35:32 -0500 Organization: A noiseless patient Spider Lines: 13 Message-ID: MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit Injection-Date: Mon, 07 Oct 2024 15:35:32 +0200 (CEST) Injection-Info: dont-email.me; posting-host="2fb237cfcd73a2d67e8da345097d3cab"; logging-data="1817380"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1/Muubx+7RpYUm/66uvPyIiCcJiJKovOfw=" User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:102.0) Gecko/20100101 Thunderbird/102.11.0 Cancel-Lock: sha1:CambQ+HgEWeuspn1phOU5f16kHU= Content-Language: en-US Bytes: 1547 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.