Freeze problem with Regular Expression

Kirk noreply at yahoo.com
Wed Jun 25 11:20:04 EDT 2008


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



More information about the Python-list mailing list