parameters: (out, scope, args, children)
docstring: {{sub <string> <regexp> <substitution>}}
         Replaces value of <string> with all instances of <regexp> replaced with <substitution>.
docstring_summary: {{sub <string> <regexp> <substitution>}}
         Replaces value of <string> with all instances of <regexp> replaced with <substitution>.
docstring_tokens: {{ sub <string > <regexp > <substitution > }} Replaces value of <string > with all instances of <regexp > replaced with <substitution > .
function: def sub(out, scope, args, children):
      """{{sub <string> <regexp> <substitution>}}
         Replaces value of <string> with all instances of <regexp> replaced with <substitution>.
      """
      len(args) == 3 or syntax_error("'sub' macro takes exactly 4 arguments.")
      string, regex, substitution = args
      if isinstance(string, list):
          return [re.sub(regex, substitution, s) for s in string]
      if not isinstance(regex, str):
          syntax_error("Invalid regular expression in 'sub' macro: '%s'" % regex)
      else:
          return re.sub(regex, substitution, string)
function_tokens: def sub ( out , scope , args , children ) : len ( args ) == 3 or syntax_error ( "'sub' macro takes exactly 4 arguments." ) string , regex , substitution = args if isinstance ( string , list ) : return [ re . sub ( regex , substitution , s ) for s in string ] if not isinstance ( regex , str ) : syntax_error ( "Invalid regular expression in 'sub' macro: '%s'" % regex ) else : return re . sub ( regex , substitution , string )