Re: Correct syntax for pathological re.search()

2024-10-21 Thread Peter J. Holzer via Python-list
On 2024-10-19 00:15:23 +0200, jak via Python-list wrote: > Peter J. Holzer ha scritto: > > As a trivial example, the regular expressions r"\\sout{" and r"\\sout\{" > > are equivalent (the \ before the { is redundant). Yet > > re.compile(s).pattern preserves the difference between the two strings. >

Re: Correct syntax for pathological re.search()

2024-10-19 Thread jak via Python-list
Peter J. Holzer ha scritto: As a trivial example, the regular expressions r"\\sout{" and r"\\sout\{" are equivalent (the \ before the { is redundant). Yet re.compile(s).pattern preserves the difference between the two strings. Hi, Allow me to be fussy: r"\\sout{" and r"\\sout\{" are similar bu

Re: Correct syntax for pathological re.search()

2024-10-18 Thread Peter J. Holzer via Python-list
On 2024-10-12 08:51:57 -0400, Thomas Passin via Python-list wrote: > On 10/12/2024 6:59 AM, Peter J. Holzer via Python-list wrote: > > On 2024-10-11 17:13:07 -0400, AVI GROSS via Python-list wrote: > > > Is there some utility function out there that can be called to show what > > > the > > > regul

Re: Correct syntax for pathological re.search()

2024-10-12 Thread Thomas Passin via Python-list
tern) \w+\\sub -Original Message- From: Python-list bounces+avi.e.gross=gmail@python.org> On Behalf Of Gilmeh Serda via Python-list Sent: Friday, October 11, 2024 10:44 AM To: python-list@python.org Subject: Re: Correct syntax for pathological re.search() On Mon, 7 Oct 2024 08:3

RE: Correct syntax for pathological re.search()

2024-10-12 Thread AVI GROSS via Python-list
. -Original Message- From: Python-list On Behalf Of Peter J. Holzer via Python-list Sent: Saturday, October 12, 2024 7:00 AM To: python-list@python.org Subject: Re: Correct syntax for pathological re.search() On 2024-10-11 17:13:07 -0400, AVI GROSS via Python-list wrote: > Is there some util

Re: Correct syntax for pathological re.search()

2024-10-12 Thread Thomas Passin via Python-list
On 10/12/2024 6:59 AM, Peter J. Holzer via Python-list wrote: On 2024-10-11 17:13:07 -0400, AVI GROSS via Python-list wrote: Is there some utility function out there that can be called to show what the regular expression you typed in will look like by the time it is ready to be used? I assume

Re: Correct syntax for pathological re.search()

2024-10-12 Thread Peter J. Holzer via Python-list
On 2024-10-11 17:13:07 -0400, AVI GROSS via Python-list wrote: > Is there some utility function out there that can be called to show what the > regular expression you typed in will look like by the time it is ready to be > used? I assume that by "ready to be used" you mean the compiled form? No,

Re: Correct syntax for pathological re.search()

2024-10-11 Thread MRAB via Python-list
dealing with a layer of backslashes. But for simple cases, ... Yes. It's called 'print'. :-) -Original Message- From: Python-list On Behalf Of Gilmeh Serda via Python-list Sent: Friday, October 11, 2024 10:44 AM To: python-list@python.org Subject: Re: Correct syntax f

RE: Correct syntax for pathological re.search()

2024-10-11 Thread AVI GROSS via Python-list
cases, ... -Original Message- From: Python-list On Behalf Of Gilmeh Serda via Python-list Sent: Friday, October 11, 2024 10:44 AM To: python-list@python.org Subject: Re: Correct syntax for pathological re.search() On Mon, 7 Oct 2024 08:35:32 -0500, Michael F. Stemper wrote: > I'

Re: Correct syntax for pathological re.search()

2024-10-09 Thread Karsten Hilbert via Python-list
Am Tue, Oct 08, 2024 at 04:59:48PM -0400 schrieb Alan Bawden via Python-list: > Karsten Hilbert writes: > >Python 3.11.2 (main, Aug 26 2024, 07:20:54) [GCC 12.2.0] on linux >Type "help", "copyright", "credits" or "license" for more > information. >>>> tex = '\

Re: Correct syntax for pathological re.search()

2024-10-08 Thread MRAB via Python-list
On 2024-10-08 21:59, Alan Bawden via Python-list wrote: Karsten Hilbert writes: Python 3.11.2 (main, Aug 26 2024, 07:20:54) [GCC 12.2.0] on linux Type "help", "copyright", "credits" or "license" for more information. >>> tex = '\sout{' >>> tex

Re: Correct syntax for pathological re.search()

2024-10-08 Thread Alan Bawden via Python-list
Karsten Hilbert writes: Python 3.11.2 (main, Aug 26 2024, 07:20:54) [GCC 12.2.0] on linux Type "help", "copyright", "credits" or "license" for more information. >>> tex = '\sout{' >>> tex '\\sout{' >>> Am I missing something ?

Re: Correct syntax for pathological re.search()

2024-10-08 Thread Karsten Hilbert via Python-list
Am Tue, Oct 08, 2024 at 08:07:04PM +0100 schrieb MRAB via Python-list: > >unwanted_tex = '\sout{' > >if unwanted_tex not in line: do_something_with_libreoffice() > > > That should be: > > unwanted_tex = r'\sout{' Hm. Python 3.11.2 (main, Aug 26 2024, 07:20:54) [GCC 12.2.0] on linux

Re: Correct syntax for pathological re.search()

2024-10-08 Thread MRAB via Python-list
On 2024-10-07 14:35, Michael F. Stemper via Python-list wrote: 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):

Re: Correct syntax for pathological re.search()

2024-10-08 Thread MRAB via Python-list
On 2024-10-08 19:30, Karsten Hilbert via Python-list wrote: Am Mon, Oct 07, 2024 at 08:35:32AM -0500 schrieb Michael F. Stemper via Python-list: 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{", lin

Re: Correct syntax for pathological re.search()

2024-10-08 Thread Karsten Hilbert via Python-list
Am Mon, Oct 07, 2024 at 08:35:32AM -0500 schrieb Michael F. Stemper via Python-list: > 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: Correct syntax for pathological re.search()

2024-10-08 Thread Jon Ribbens via Python-list
On 2024-10-07, Stefan Ram wrote: > "Michael F. Stemper" wrote or quoted: >>For now, I'll use the "r" in a cargo-cult fashion, until I decide which >>syntax I prefer. (Is there any reason that one or the other is preferable?) > > I'd totally go with the r-style notation! > > It's got one bumme

Correct syntax for pathological re.search()

2024-10-08 Thread Michael F. Stemper via Python-list
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 k

Re: Correct syntax for pathological re.search()

2024-10-08 Thread Pieter van Oostrum via Python-list
r...@zedat.fu-berlin.de (Stefan Ram) writes: > "Michael F. Stemper" wrote or quoted: > > path = r'C:\Windows\example' + '\\' > You could even omit the '+'. Then the concatenation is done at parsing time instead of run time. -- Pieter van Oostrum www: http://pieter.vanoostrum.org/ PGP key: [8DA

Re: Correct syntax for pathological re.search()

2024-10-08 Thread Michael F. Stemper via Python-list
On 07/10/2024 08.56, Stefan Ram wrote: "Michael F. Stemper" wrote or quoted: if not re.search("\\sout\{", line): So, if you're not down to slap an "r" before your string literals, you're going to end up doubling down on every backslash. Never heard of that before, but it did the trick