Variable-width lookbehind
OKB (not okblacke)
brenNOSPAMbarn at NObrenSPAMbarn.net
Mon Nov 19 21:28:42 EST 2007
Gary Herron wrote:
> OKB (not okblacke) wrote:
>> Paul Rubin wrote:
>>
>>
>>> "OKB (not okblacke)" <brenNOSPAMbarn at NObrenSPAMbarn.net> writes:
>>>
>>>> For years now Python has not supported variable-length
>>>> lookbehinds.
>>>>
>>> I'm not sure what that is and the perl links you gave don't work,
>>> but it sounds evil.
>>>
>>
>> The links work fine for me. . .
>>
>> You're not sure what "variable-length lookbehinds" means?
>>
>> Lookbehind is something that Python regexps already have. You can
>> do "(?<=one)two" to match "two" only if it's preceded by "one",
>> and you can do "(?<!one)two" to match "two" only if it's NOT
>> preceded by "one". What you can't do is "(?<=one|three)two",
>> because Python requires that the lookbehind contain only strings
>> of a fixed length. What I'm asking about is the possibility of
>> lifting this limitation, to allow the lookbehinds (positive and
>> negative) to contain general regexps. I don't see how this is in
>> any way evil.
>>
> If not *evil*, then how about *unreadable*. Regular expressions
> are powerful, but nearly unreadable as they are. Allowing them to
> be even more complex just gets one step closer to *absolutely
> unreadable*.
Well, it doesn't really change the potential for unreadability. It
just allows people to put existing unreadable (or readable) regexps
inside a particular kind of group.
> Are you willing to implement it and lobby for it's inclusion? If
> so, good, we'll look at it. If not, then perhaps you understand
> perfectly why it's not yet included.
Yeah, this is what I was expecting, and it's a valid point. I was
just wondering if this had ever been floated before. I personally have
nowhere near the chops to write something like a regex engine (that's
why I like using Python -- it's got one built in!).
--
--OKB (not okblacke)
Brendan Barnwell
"Do not follow where the path may lead. Go, instead, where there is
no path, and leave a trail."
--author unknown
More information about the Python-list
mailing list