- fixed split behaviour on empty matches

- fixed compiler problems when using locale/unicode flags

- fixed group/octal code parsing in sub/subn templates
This commit is contained in:
Fredrik Lundh 2000-06-30 00:27:46 +00:00
parent 5d6ae76c09
commit 01016fe972
4 changed files with 55 additions and 42 deletions

View file

@ -109,16 +109,13 @@ def _subn(pattern, template, string, count=0):
m = c.search()
if not m:
break
j = m.start()
if j > i:
append(string[i:j])
b, e = m.span()
if i < b:
append(string[i:b])
append(filter(m))
i = m.end()
if i <= j:
break
i = e
n = n + 1
if i < len(string):
append(string[i:])
append(string[i:])
return string[:0].join(s), n
def _split(pattern, string, maxsplit=0):
@ -128,7 +125,7 @@ def _split(pattern, string, maxsplit=0):
append = s.append
extend = s.extend
c = pattern.scanner(string)
g = c.groups
g = pattern.groups
while not maxsplit or n < maxsplit:
m = c.search()
if not m: