Freeze problem with Regular Expression

cirfu circularfunc at yahoo.se
Wed Jun 25 18:40:08 CEST 2008


On 25 Juni, 17:20, Kirk <nore... at yahoo.com> wrote:
> Hi All,
> the following regular expression matching seems to enter in a infinite
> loop:
>
> ################
> import re
> text = ' MSX INTERNATIONAL HOLDINGS ITALIA srl (di seguito MSX ITALIA)
> una '
> re.findall('[^A-Z|0-9]*((?:[0-9]*[A-Z]+[0-9|a-z|\-]*)+\s*[a-z]*\s*(?:[0-9]
> *[A-Z]+[0-9|a-z|\-]*\s*)*)([^A-Z]*)$', text)
> #################
>
> No problem with perl with the same expression:
>
> #################
> $s = ' MSX INTERNATIONAL HOLDINGS ITALIA srl (di seguito MSX ITALIA) una
> ';
> $s =~ /[^A-Z|0-9]*((?:[0-9]*[A-Z]+[0-9|a-z|\-]*)+\s*[a-z]*\s*(?:[0-9]*[A-
> Z]+[0-9|a-z|\-]*\s*)*)([^A-Z]*)$/;
> print $1;
> #################
>
> I've python 2.5.2 on Ubuntu 8.04.
> any idea?
> Thanks!
>
> --
> Kirk


what are you trying to do?



More information about the Python-list mailing list