Making regex suck less
Ben Wolfson
wolfson at midway.uchicago.edu
Thu Sep 5 02:56:24 EDT 2002
On Thu, 05 Sep 2002 06:41:14 GMT, "Fredrik Lundh" <fredrik at pythonware.com>
wrote:
>Bengt Richter wrote:
>
>> >you can ask SRE to dump the internal parse tree
>> >to stdout:
>> >
>> >>>> sre.compile("[a-z]\d*", sre.DEBUG)
>> >in
>> > range (97, 122)
>> >max_repeat 0 65535
>> > in
>> > category category_digit
>> >
>> >turning this into 'English' is left as an exercise etc.
>>
>> Interesting, thanks. Does the above mean that sre can't fully match
>> 'a'+'9'*65537
>> ?
>
>in this context, 65535 represents any number:
Doesn't that cause problems for something like this?
>>> m=re.compile(r'\d{0,65535}a').match(('9'*1000000)+'a')
>>> len(m.group(0))
1000001
--
BTR
You're going to set me up as a kind of slovenly attached pig that
Jack Kornfeld can slice down in his violent zen compassion?
-- Larry Block
More information about the Python-list
mailing list