split hangs

Harald Kirsch kirschh at lionbioscience.com
Thu Dec 28 03:13:33 EST 2000


jp at ulgo.koti.com.pl (Jacek Pop³awski) writes:

> Aahz Maruch wrote:
> >What is the regex?
> 
> ourregex=re.compile(r'(<(?:[^<>"]+(?:"[^"]*")?)+>)')

Yes, something is very strange with this type of regex. Run the
following program. It shows strange behaviour with 1.5.2 on Linux as
well as with 2.0 on IRIX.

The regex looks harmless. Is this a bug or do we run into some
backtracking problem here?


########################################################################
import re
import sys

boing = re.compile(r'(<(?:[^<>"]+(?:"[^"]*")?)+>)')

s = 'p < 0.05, all data in arbitrary'

for i in range(1, len(s)):
  t = s[0:i]
  boing.search(t)
  print "survived `%s'"%t


print "----------------------------------"
########################################################################

Harald Kirsch


-- 
----------------+------------------------------------------------------
Harald Kirsch   | kirschh at lionbioscience.com | "How old is the epsilon?"
LION Bioscience | +49 6221 4038 172          |        -- Paul Erdös



More information about the Python-list mailing list