[issue11198] re sub subn backreferrence too few replacements

muxum report at bugs.python.org
Fri Feb 11 20:29:07 CET 2011


New submission from muxum <mxgnone at gmx.de>:

#download/try this: http://ideone.com/QA6Fg

from re import *
 
s = 'a->b\na->b\nc->b\nc->b\na->d\na->d\ne->b\ne->b\na->f\na->f\ng->b\ng->b\na->h\na->h\ni->b\ni->b\na->j\na->j\nk->b\nk->b\n'
res = subn(r"(.*\n)(\1)+",r"replaced:\1",s,M)
 
print("output: " + res[0])
print("replace count: %d" % res[1])
 
# if it works right the next print wont show
if res[1] == 8: print("WEIRD: too few replacements ("+str(res[1])+")")

#i'd expect this to replace all ocurrences not only the first 8 times

----------
components: Regular Expressions
messages: 128422
nosy: muxum
priority: normal
severity: normal
status: open
title: re sub subn backreferrence too few replacements
type: behavior
versions: Python 2.6, Python 3.1

_______________________________________
Python tracker <report at bugs.python.org>
<http://bugs.python.org/issue11198>
_______________________________________


More information about the Python-bugs-list mailing list