parameters: (pattern, repl, string, count=0, flags=0, pos=None, endpos=None, concurrent=None, **kwargs)
return_statement: return _regex.sub(
          pattern, (compile_replace(pattern, repl) if is_replace or is_string else repl), string,
          count, flags, pos, endpos, concurrent, **kwargs
      )
docstring: Wrapper for `sub`.
docstring_summary: Wrapper for `sub`.
docstring_tokens: Wrapper for sub .
function: def sub(pattern, repl, string, count=0, flags=0, pos=None, endpos=None, concurrent=None, **kwargs):
      """Wrapper for `sub`."""
  
      is_replace = _is_replace(repl)
      is_string = isinstance(repl, (_util.string_type, _util.binary_type))
      if is_replace and repl.use_format:
          raise ValueError("Compiled replace cannot be a format object!")
  
      pattern = compile_search(pattern, flags)
      return _regex.sub(
          pattern, (compile_replace(pattern, repl) if is_replace or is_string else repl), string,
          count, flags, pos, endpos, concurrent, **kwargs
      )
function_tokens: def sub ( pattern , repl , string , count = 0 , flags = 0 , pos = None , endpos = None , concurrent = None , * * kwargs ) : is_replace = _is_replace ( repl ) is_string = isinstance ( repl , ( _util . string_type , _util . binary_type ) ) if is_replace and repl . use_format : raise ValueError ( "Compiled replace cannot be a format object!" ) pattern = compile_search ( pattern , flags ) return _regex . sub ( pattern , ( compile_replace ( pattern , repl ) if is_replace or is_string else repl ) , string , count , flags , pos , endpos , concurrent , * * kwargs )