parameters: (self, repl)
return_statement: return self.addParseAction(pa)
docstring: 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>"
docstring_summary: 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>`_.
docstring_tokens: 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 > _ .
function: 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)
function_tokens: 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 )