(self, repl)
return self.addParseAction(pa)
r"""
        Return Regex with an attached parse action to transform the parsed
        result as if called using `re.sub(expr, repl, string) <https://docs.python.org/3/library/re.html#re.sub>`_.

        Example::

            make_html = Regex(r"(\w+):(.*?):").sub(r"<\1>\2</\1>")
            print(make_html.transformString("h1:main title:"))
            # prints "<h1>main title</h1>"
r"""
        Return Regex with an attached parse action to transform the parsed
        result as if called using `re.sub(expr, repl, string) <https://docs.python.org/3/library/re.html#re.sub>`_.
r Return Regex with an attached parse action to transform the parsed result as if called using re . sub ( expr repl string ) <https : // docs . python . org / 3 / library / re . html#re . sub > _ .
def sub(self, repl):
        r"""
        Return Regex with an attached parse action to transform the parsed
        result as if called using `re.sub(expr, repl, string) <https://docs.python.org/3/library/re.html#re.sub>`_.

        Example::

            make_html = Regex(r"(\w+):(.*?):").sub(r"<\1>\2</\1>")
            print(make_html.transformString("h1:main title:"))
            # prints "<h1>main title</h1>"
        """
        if self.asGroupList:
            warnings.warn("cannot use sub() with Regex(asGroupList=True)",
                           SyntaxWarning, stacklevel=2)
            raise SyntaxError()

        if self.asMatch and callable(repl):
            warnings.warn("cannot use sub() with a callable with Regex(asMatch=True)",
                           SyntaxWarning, stacklevel=2)
            raise SyntaxError()

        if self.asMatch:
            def pa(tokens):
                return tokens[0].expand(repl)
        else:
            def pa(tokens):
                return self.re.sub(repl, tokens[0])
        return self.addParseAction(pa)
def sub ( self , repl ) : if self . asGroupList : warnings . warn ( "cannot use sub() with Regex(asGroupList=True)" , SyntaxWarning , stacklevel = 2 ) raise SyntaxError ( ) if self . asMatch and callable ( repl ) : warnings . warn ( "cannot use sub() with a callable with Regex(asMatch=True)" , SyntaxWarning , stacklevel = 2 ) raise SyntaxError ( ) if self . asMatch : def pa ( tokens ) : return tokens [ 0 ] . expand ( repl ) else : def pa ( tokens ) : return self . re . sub ( repl , tokens [ 0 ] ) return self . addParseAction ( pa )