RE: Correct syntax for pathological re.search()

Liste des GroupesRevenir à cl python 
Sujet : RE: Correct syntax for pathological re.search()
De : <avi.e.gross (at) *nospam* gmail.com>
Groupes : comp.lang.python
Date : 12. Oct 2024, 16:10:41
Autres entêtes
Message-ID : <mailman.23.1728742245.4695.python-list@python.org>
References : 1 2 3 4 5
User-Agent : Microsoft Outlook 16.0
Peter,

Matthew understood what I was hinting at in one way and you in another.

The question asked how to add some power of two backslashes or make other
changes, so the RE functionality sees what you want. The goal is to see what
happens when one or more intermediate evaluations may change the string.

So, a simple print may suffice as a parallel way to force the same
evaluations.

Thomas made his point. And, I am starting to feel like I need to change my
name to something like Luke since this discussion must be gospel.

FYI, I was not planning on posting at all. Time to detach.


-----Original Message-----
From: Python-list <python-list-bounces+avi.e.gross=gmail.com@python.org> 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 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, there doesn't seem to be a way to dump that. You can

    p = re.compile("\\sout{")
    print(p.pattern)

but that just prints the input string, which you could do without
compiling it first.

But - without having looked at the implementation - it's far from clear
that the compiled form would be useful to the user. It's probably some
kind of state machine, and a large table of state transitions isn't very
readable.

There are a number of websites which visualize regular expressions.
Those are probably better for debugging a regular expression than
anything the re module could reasonably produce (although with the
caveat that such a web site would use a different implementation and
therefore might produce different results).

        hp

--
   _  | Peter J. Holzer    | Story must make more sense than reality.
|_|_) |                    |
| |   | hjp@hjp.at         |    -- Charles Stross, "Creative writing
__/   | http://www.hjp.at/ |       challenge!"


Date Sujet#  Auteur
7 Oct 24 * Correct syntax for pathological re.search()28Michael F. Stemper
7 Oct 24 +* Re: Correct syntax for pathological re.search()6Stefan Ram
7 Oct 24 i`* Re: Correct syntax for pathological re.search()5Michael F. Stemper
7 Oct 24 i `* Re: Correct syntax for pathological re.search()4Stefan Ram
7 Oct 24 i  +- Re: Correct syntax for pathological re.search()1Jon Ribbens
8 Oct 24 i  `* Re: Correct syntax for pathological re.search()2Pieter van Oostrum
9 Oct 24 i   `- Re: Correct syntax for re.search() (Posting On Python-List Prohibited)1Lawrence D'Oliveiro
8 Oct 24 +- Re: Correct syntax for pathological re.search()1Karsten Hilbert
8 Oct 24 +- Re: Correct syntax for pathological re.search()1MRAB
8 Oct 24 +* Re: Correct syntax for pathological re.search()3MRAB
8 Oct 24 i`* Re: Correct syntax for pathological re.search()2Stefan Ram
8 Oct 24 i `- Re: Correct syntax for pathological re.search()1Stefan Ram
8 Oct 24 +* Re: Correct syntax for pathological re.search()4Karsten Hilbert
8 Oct 24 i`* Re: Correct syntax for pathological re.search()3Alan Bawden
9 Oct 24 i +- Re: Correct syntax for pathological re.search()1MRAB
9 Oct 24 i `- Re: Correct syntax for pathological re.search()1Karsten Hilbert
11 Oct 24 +- Re: Correct syntax for pathological re.search()1<avi.e.gross
12 Oct 24 +- Re: Correct syntax for pathological re.search()1MRAB
12 Oct 24 +* Re: Correct syntax for pathological re.search()2Peter J. Holzer
12 Oct 24 i`- Re: Correct syntax for pathological re.search()1Stefan Ram
12 Oct 24 +- Re: Correct syntax for pathological re.search()1Thomas Passin
12 Oct 24 +- Re: Correct syntax for pathological re.search()1<avi.e.gross
12 Oct 24 +- Re: Correct syntax for pathological re.search()1Thomas Passin
13 Oct 24 +- Re: Correct syntax for pathological re.search()1Stefan Ram
18 Oct 24 `* Re: Correct syntax for pathological re.search()4Peter J. Holzer
19 Oct 24  `* Re: Correct syntax for pathological re.search()3jak
21 Oct 24   `* Re: Correct syntax for pathological re.search()2Peter J. Holzer
21 Oct 24    `- Re: Correct syntax for pathological re.search()1Stefan Ram

Haut de la page

Les messages affichés proviennent d'usenet.

NewsPortal