def subn(self, repl, string, count=0):
if (isinstance(repl, SourcedString) or
isinstance(string, SourcedString)):
result = ''
pos = 0
n = 0
for match in self.pattern.finditer(string):
result += string[pos:match.start()]
result += repl
pos = match.end()
n += 1
if count and n==count: break
result += string[pos:]
return result, n
else:
return self.pattern.subn(repl, string, count)
评论列表
文章目录