Issues with Python 2.2. regex
Peter Milliken
peter.milliken at gtech.com
Thu Dec 20 22:37:28 EST 2001
The re package in previous versions of Python had some form of weird problem
with named groups which "changed" in 2.2 - obviously a fix attempt that
didn't quite get there :-)
I never reported the issue in the previous versions, there is still some
form of problem. I never attempted to isolate the behaviour because I was
desparate for time to get the code working, then I promptly forgot about it
:-). I attempted to use the program the other day with 2.2c1 and found it
"broken", a but of kludging around with the previous kludge caused the re
expression to work, so something changed!
If you have the time to isolate the behaviour properly (I still don't :-))
then please do so, it would be nice to get my kludge out of my code (BTW, I
fixed my problem by repeating the named group at the beginning and end of
the expression being compiled - it was only the first and last expression
that had problems, so I found if I repeated exactly the same name and
pattern as the first/last ones then it worked :-) i.e.
"(?P<name1>patt1)(?P<name1>patt1)(?P<name2>patt2)(?P<name3>patt3).....(?P<na
mex>pattx)(?P<namex>pattx)" Otherwise the first and last patterns were being
ignored!
Peter
"Jürgen Hermann" <jh at web.de> wrote in message
news:9vtm2e$9fs$06$1 at news.t-online.com...
> Hi!
>
> Are there any known changes/problems with named groups in Python 2.2 re?
>
> Given this:
>
> (?P<heading>^\s*(?P<hmarker>=+)\s.*\s(?P=hmarker) $)
>
> Python 2.2 reports groups for the nested named parens, while previous
> versions do not. If this is unexpected, I'll isolate this effect in a
little
> script.
>
> Bye, Jürgen
>
>
More information about the Python-list
mailing list