def __call__(self, matchobj): if count == 0: return re._expand(re.compile(re.escape(pattern)), Match(matchobj), replacement) else: self.calls += 1 if self.calls == count: return re._expand(pattern, Match(matchobj), replacement) else: return matchobj.group(0)
def __call__(self, matchobj): if count == 0: match = Match(matchobj) try: if self.prevmatch and match.group(0) == '' and match.start( 0) == self.prevmatch.end(0): return match.group(0) else: return re._expand(compiled, match, replacement) finally: self.prevmatch = match else: self.calls += 1 if self.calls == count: return re._expand(compiled, Match(matchobj), replacement) else: return matchobj.group(0)
def expand(self,template): """ Expand the matching partion using a re.sub template. """ import re if self.pattern is None: return self.other.expand(self,tempate) return re._expand(self.pattern,self,template)
def _r(m): class _m(): def __init__(self, m): self.m=m self.string=m.string def group(self, n): return m.group(n) or "" return re._expand(pattern, _m(m), replacement)
def _r(m): # Now this is ugly. # Python has a "feature" where unmatched groups return None # then re.sub chokes on this. # see http://bugs.python.org/issue1519638 # this works around and hooks into the internal of the re module... # the match object is replaced with a wrapper that # returns "" instead of None for unmatched groups class _m(): def __init__(self, m): self.m=m self.string=m.string def group(self, n): return m.group(n) or "" return re._expand(pattern, _m(m), replacement)
def _r(m): # Now this is ugly. # Python has a "feature" where unmatched groups return None # then re_sub chokes on this. # see http://bugs.python.org/issue1519638 # this works around and hooks into the internal of the re module... # the match object is replaced with a wrapper that # returns "" instead of None for unmatched groups class _m(): def __init__(self, m): self.m=m self.string=m.string def group(self, n): return m.group(n) or "" return re._expand(pattern, _m(m), replacement)
def expand(cls, match, expand): # If use expand directly, the url-decoded context will be decoded again, which create a security # issue. Hack expand to quote the text before expanding return re._expand(match.re, cls._EncodedMatch(match), expand)
def expand(self, template): return re._expand(self.re, self, template)
def expand(self, template): import re return re._expand(self.__re, self, template)
def expand(self, template): """Return the string obtained by doing backslash substitution and resolving group references on template.""" import re return re._expand(self.re, self, template)
def update_event(self, inp=-1): self.set_output_val( 0, re._expand(self.input(0), self.input(1), self.input(2)))