37 lines
1.3 KiB
Plaintext
37 lines
1.3 KiB
Plaintext
From: aa8vb at vislab.epa.gov (Randall Hopper)
|
|
Date: Tue, 6 Apr 1999 11:39:17 GMT
|
|
Subject: Possible regex match bug (re module)
|
|
In-Reply-To: <000001be7fc9$bdb0fec0$65a22299@tim>; from Tim Peters on Mon, Apr 05, 1999 at 09:06:45PM -0400
|
|
References: <19990405084819.B802985@vislab.epa.gov> <000001be7fc9$bdb0fec0$65a22299@tim>
|
|
Message-ID: <19990406073917.B867123@vislab.epa.gov>
|
|
X-UID: 1647
|
|
|
|
Tim Peters:
|
|
|Same as in Perl, you're going to have to write a hairier regexp with only
|
|
|one interesting group, or give the interesting groups different names and
|
|
|sort them out after the match (in an alternation involving named groups, at
|
|
|most one will be non-None after a match). Here's a discouraging <wink>
|
|
|example of the former approach:
|
|
|
|
|
|>>> p = re.compile(r"([-=])\1\1(?P<id>((?!\1).)*)\1\1\1").match
|
|
|
|
I didn't parse your reply carefully enough. The "interesting groups
|
|
different names" approach is the one I took, and you're not advocating the
|
|
"hairier" form.
|
|
|
|
I guess what threw me with named groups is that they are identified by
|
|
names (like variables) and not position numbers ($1,$2,...), so
|
|
context-sensitive assignment seemed to make sense. E.g.:
|
|
"if a == b { id = b } else { id = c }"
|
|
|
|
I'll use different names in the future, and just be thinking numbers. ;-)
|
|
|
|
Thanks,
|
|
|
|
Randall
|
|
|
|
|
|
|
|
|
|
|