Is there a maximum length of a regular expression in python?
Steve Holden
steve at holdenweb.com
Fri Jan 20 21:06:40 EST 2006
Bryan Olson wrote:
> Roy Smith wrote:
>
>> olekristianvillabo at gmail.com wrote:
>>
>>
>>
>>>I have a regular expression that is approximately 100k bytes. (It is
>>>basically a list of all known norwegian postal numbers and the
>>>corresponding place with | in between. I know this is not the intended
>>>use for regular expressions, but it should nonetheless work.
>>>
>>>the pattern is
>>>ur'(N-|NO-)?(5259 HJELLESTAD|4026 STAVANGER|4027 STAVANGER........|8305
>>>SVOLVÆR)'
>>>
>>>The error message I get is:
>>>RuntimeError: internal error in regular expression engine
>>
>>
>>I don't know of any stated maximum length, but I'm not at all surprised
>>this causes the regex compiler to blow up. This is clearly a case of regex
>>being the wrong tool for the job.
>
>
> Does no one care about an internal error in the regular expression
> engine?
>
>
Not one that requires parsing a 100 kilobyte re that should be replaced
by something more sensible, no.
regards
Steve
--
Steve Holden +44 150 684 7255 +1 800 494 3119
Holden Web LLC www.holdenweb.com
PyCon TX 2006 www.python.org/pycon/
More information about the Python-list
mailing list