Deutsch   English   Français   Italiano  
<mailman.21.1728731108.4695.python-list@python.org>

View for Bookmarking (what is this?)
Look up another Usenet article

Path: ...!news.mixmin.net!news.swapon.de!fu-berlin.de!uni-berlin.de!not-for-mail
From: "Peter J. Holzer" <hjp-python@hjp.at>
Newsgroups: comp.lang.python
Subject: Re: Correct syntax for pathological re.search()
Date: Sat, 12 Oct 2024 12:59:58 +0200
Lines: 63
Message-ID: <mailman.21.1728731108.4695.python-list@python.org>
References: <ve0o34$1nep4$1@dont-email.me>
 <MQaOO.3313338$EVn.2054758@fx04.ams4>
 <011301db1c22$5e7519c0$1b5f4d40$@gmail.com>
 <20241012105958.cbctekv7vustleha@hjp.at>
Mime-Version: 1.0
Content-Type: multipart/signed; micalg=pgp-sha512;
 protocol="application/pgp-signature"; boundary="j5p3p5bfujs6sx6l"
X-Trace: news.uni-berlin.de j+4BY6MlyD3imCg8V5wSOgWw4pi0iWhZ/xMUPN2JQf8A==
Cancel-Lock: sha1:8GccUE/90aPMMCNL3FS7f6cPMGU= sha256:tydMFRo8CHhcglb/tdxgORZWdkddOutgmRzuK2OXvyU=
Return-Path: <hjp-python@hjp.at>
X-Original-To: python-list@python.org
Delivered-To: python-list@mail.python.org
Authentication-Results: mail.python.org; dkim=none reason="no signature";
 dkim-adsp=none (unprotected policy); dkim-atps=neutral
X-Spam-Status: OK 0.000
X-Spam-Evidence: '*H*': 1.00; '*S*': 0.00; 'content-
 type:multipart/signed': 0.05; 'debugging': 0.07; 'content-
 type:application/pgp-signature': 0.09; 'expression': 0.09;
 'filename:fname piece:asc': 0.09; 'filename:fname
 piece:signature': 0.09; 'filename:fname:signature.asc': 0.09;
 'prints': 0.09; 'string,': 0.09; 'user.': 0.09; 'utility': 0.09;
 'that.': 0.15; '"creative': 0.16; '__/': 0.16; 'avi': 0.16;
 'challenge!"': 0.16; 'compiled': 0.16; 'expressions.': 0.16;
 'from:addr:hjp-python': 0.16; 'from:addr:hjp.at': 0.16;
 'from:name:peter j. holzer': 0.16; 'gross': 0.16; 'hjp@hjp.at':
 0.16; 'holzer': 0.16; 'machine,': 0.16; 'reality.': 0.16;
 'stross,': 0.16; 'subject:syntax': 0.16; 'url-ip:212.17.106/24':
 0.16; 'url-ip:212.17/16': 0.16; 'url:hjp': 0.16; 'visualize':
 0.16; '|_|_)': 0.16; 'wrote:': 0.16; 'probably': 0.17; 'to:addr
 :python-list': 0.20; 'input': 0.21; 'anything': 0.25; "isn't":
 0.27; 'function': 0.27; 'sense': 0.28; 'seem': 0.31; 'looked':
 0.31; 'module': 0.31; "doesn't": 0.32; 'assume': 0.32; 'python-
 list': 0.32; 'but': 0.32; 'subject:for': 0.33; 'there': 0.33;
 'mean': 0.34; 'header:In-Reply-To:1': 0.34; 'those': 0.36; "it's":
 0.37; 'way': 0.38; 'could': 0.38; 'use': 0.39; 'table': 0.39;
 'received:212': 0.62; 'skip:r 20': 0.64; 'clear': 0.64; 'produce':
 0.65; 'look': 0.65; 'received:userid': 0.66; 'url-ip:212/8': 0.69;
 'site': 0.70; 'received:at': 0.84; 'transitions': 0.84;
 'websites': 0.95
Mail-Followup-To: python-list@python.org
Content-Disposition: inline
In-Reply-To: <011301db1c22$5e7519c0$1b5f4d40$@gmail.com>
X-BeenThere: python-list@python.org
X-Mailman-Version: 2.1.39
Precedence: list
List-Id: General discussion list for the Python programming language
 <python-list.python.org>
List-Unsubscribe: <https://mail.python.org/mailman/options/python-list>,
 <mailto:python-list-request@python.org?subject=unsubscribe>
List-Archive: <https://mail.python.org/pipermail/python-list/>
List-Post: <mailto:python-list@python.org>
List-Help: <mailto:python-list-request@python.org?subject=help>
List-Subscribe: <https://mail.python.org/mailman/listinfo/python-list>,
 <mailto:python-list-request@python.org?subject=subscribe>
X-Mailman-Original-Message-ID: <20241012105958.cbctekv7vustleha@hjp.at>
X-Mailman-Original-References: <ve0o34$1nep4$1@dont-email.me>
 <MQaOO.3313338$EVn.2054758@fx04.ams4>
 <011301db1c22$5e7519c0$1b5f4d40$@gmail.com>
Bytes: 5993


--j5p3p5bfujs6sx6l
Content-Type: text/plain; charset=us-ascii
Content-Disposition: inline
Content-Transfer-Encoding: quoted-printable

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 =3D 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

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

--j5p3p5bfujs6sx6l
Content-Type: application/pgp-signature; name="signature.asc"

-----BEGIN PGP SIGNATURE-----

iQIzBAABCgAdFiEETtJbRjyPwVTYGJ5k8g5IURL+KF0FAmcKVqgACgkQ8g5IURL+
KF3UaxAAgcW8z/AEatfZ8rsmA3Xw2TLE6Uc/33Em3+4iUHNNaDZwYEYCs9InNviq
kmChc5eqpvbdbHwzSo6nMRUKoWIff8LWYTSjvk0/eFTngzP5nS87cUgCKqd2AlFr
oH+tmxtRBShy6gJw8Zp9nZo4eMyk2jDrAkWrPRnM78WJ1XR6EgQ/xQtNEfLJDnEv
wLczdzhg9Q5yxAZkcx/+NMf1kCtkSszR2f05lglLgoKhcMK45d71XWtRJaVpOHY4
y/k+avJT7I7OTTR0rEdCJ9Plb6z9tEtkcsSOD6Nk2CyaTt/UNcrRLN/oE6EKZmnm
YWnmkTMKtVhM8LLi7/KzThkY8celLwEfDdh7yvZKh1pcVabf+YvSY/A/MxBwDpQS
G6xbugimLDv4eY8dYtjgC3E3UYlpELOb4hfMbrJ9sbXKevLUh5HwQGLDY+psJsYx
FRtACWb/MLmj8SaFFFe60DUigx6JLEJCPLanAtuo+PRIfigDRtnbSP4awctvULRY
Q5bjftnbLiR7ZUvuZTaRxF2vHBV4a2EQCGIbzqzDoM5bt1cMjj60H+VKG4+2QeYR
+x4lj/7gKywo9aVpPFT9ppfLR2Dyd9wZielnRBAc6QckoYVBow3eGIKZRq8F16gO
kmibo1lUfcc+rW2n49dKhRme8T6eZ8yzPJUntnIgOfUkItQ+Y8M=
=K5ph
-----END PGP SIGNATURE-----

--j5p3p5bfujs6sx6l--