Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > fr.comp.lang.python > #3994

Re: Propriétés Unicode dans les regex Python

Path csiph.com!news.mixmin.net!aioe.org!kHnzHQPYRqPEXuGPl1BLfw.user.46.165.242.75.POSTED!not-for-mail
From Alain Ketterlin <alain@universite-de-strasbourg.fr.invalid>
Newsgroups fr.comp.lang.python
Subject Re: Propriétés Unicode dans les regex Python
Date Sun, 06 Nov 2022 10:24:28 +0100
Organization Université de Strasbourg
Message-ID <87mt94306r.fsf@universite-de-strasbourg.fr.invalid> (permalink)
References <tk67uo$1b37$1@cabale.usenet-fr.net>
Mime-Version 1.0
Content-Type text/plain; charset=utf-8
Content-Transfer-Encoding quoted-printable
Injection-Info gioia.aioe.org; logging-data="7809"; posting-host="kHnzHQPYRqPEXuGPl1BLfw.user.gioia.aioe.org"; mail-complaints-to="abuse@aioe.org";
User-Agent Gnus/5.13 (Gnus v5.13) Emacs/25.2 (gnu/linux)
Cancel-Lock sha1:zxxeVgdRePouiwje93ydYd2J1Jc=
X-Notice Filtered by postfilter v. 0.9.2
Xref csiph.com fr.comp.lang.python:3994

Show key headers only | View raw


Olivier Miakinen <om+news@miakinen.net> writes:

> Je viens de me rendre compte que dans Python 3.8.10 les propriétés Unicode
> \p{xx} et \P{xx} ne sont pas supportées dans les regex :
>
> <https://www.pcre.org/original/doc/html/pcresyntax.html#SEC4>
> <https://www.pcre.org/original/doc/html/pcresyntax.html#SEC5>
>
>
> J'obtiens :
>   File "/usr/lib/python3.8/sre_parse.py", line 426, in _escape
>     raise source.error("bad escape %s" % escape, len(escape))
> re.error: bad escape \p at position 0

Oui, re ne fournit qu'une partie des "escapes" de pcre (il manque aussi
\h et \v et d'autres).

> Est-ce que quelqu'un sait si c'est supporté dans une autre version de
> Python, ou s'il est prévu que ça le soit un jour ?

Je ne sais pas, mais je sais qu'une bibliothèque du niveau de PCRE est
un très gros boulot, et pas forcément une priorité pour Python
j'imagine.

Cela étant, la doc mentionne une bibliothèque "regex", qui apparemment a
bonne réputation. Je n'en sais pas plus.

https://docs.python.org/3/library/re.html ("See also" à la fin de l'intro)

https://stackoverflow.com/questions/7063420/perl-compatible-regular-expression-pcre-in-python

(Le second lien est une réponse ancienne, mais qui me semble bien
informée.)

-- Alain.

Back to fr.comp.lang.python | Previous | NextPrevious in thread | Next in thread | Find similar


Thread

Propriétés Unicode dans les regex Python Olivier Miakinen <om+news@miakinen.net> - 2022-11-05 18:53 +0100
  Re: Propriétés Unicode dans les regex Python Alain Ketterlin <alain@universite-de-strasbourg.fr.invalid> - 2022-11-06 10:24 +0100
    Re: Propriétés Unicode dans les regex Python Olivier Miakinen <om+news@miakinen.net> - 2022-11-06 19:46 +0100
  Re: Propriétés Unicode dans les regex Python ast <ast@invalid> - 2022-11-06 20:29 +0100
    Re: Propriétés Unicode dans les regex Python Dominique <zzz@aol.com> - 2022-11-09 10:52 +0100
      Re: Propriétés Unicode dans les regex Python Dominique <zzz@aol.com> - 2022-11-09 14:46 +0100
    Re: Propriétés Unicode dans les regex Python Olivier Miakinen <om+news@miakinen.net> - 2022-11-09 11:44 +0100
      Re: Propriétés Unicode dans les regex Python Alain Ketterlin <alain@universite-de-strasbourg.fr.invalid> - 2022-11-09 14:13 +0100
        Re: Propriétés Unicode dans les regex Python Olivier Miakinen <om+news@miakinen.net> - 2022-11-09 15:12 +0100
          Re: Propriétés Unicode dans les regex Python Alain Ketterlin <alain@universite-de-strasbourg.fr.invalid> - 2022-11-09 19:42 +0100
            Re: Propriétés Unicode dans les regex Python Olivier Miakinen <om+news@miakinen.net> - 2022-11-09 20:09 +0100
        Re: Propriétés Unicode dans les regex Python Olivier Miakinen <om+news@miakinen.net> - 2022-11-09 15:22 +0100
          Re: Propriétés Unicode dans les regex Python Olivier Miakinen <om+news@miakinen.net> - 2022-11-09 17:07 +0100
            Re: Propriétés Unicode dans les regex Python Alain Ketterlin <alain@universite-de-strasbourg.fr.invalid> - 2022-11-09 19:46 +0100
              Re: Propriétés Unicode dans les regex Python Olivier Miakinen <om+news@miakinen.net> - 2022-11-09 19:52 +0100
          Re: Propriétés Unicode dans les regex Python ast <ast@invalid> - 2022-11-10 14:32 +0100
        Re: Propriétés Unicode dans les regex Python ast <ast@invalid> - 2022-11-10 14:29 +0100

csiph-web