r"""
    thin wrapper around re.sub
    regex_replace

    MULTILINE and DOTALL are on by default in all util_regex functions

    Args:
        regex (str): pattern to find
        repl (str): replace pattern with this
        text (str): text to modify

    Returns:
        str: modified text

    Example1:
        >>> # ENABLE_DOCTEST
        >>> from utool.util_regex import *  # NOQA
        >>> regex = r'\(.*\):'
        >>> repl = '(*args)'
        >>> text = '''def foo(param1,
        ...                   param2,
        ...                   param3):'''
        >>> result = regex_replace(regex, repl, text)
        >>> print(result)
        def foo(*args)

    Example2:
        >>> # ENABLE_DOCTEST
        >>> from utool.util_regex import *  # NOQA
        >>> import utool as ut
        >>> regex = ut.named_field_regex([('keyword', 'def'), ' ', ('funcname', '.*'), '\(.*\):'])
        >>> repl = ut.named_field_repl([('funcname',), ('keyword',)])
        >>> text = '''def foo(param1,
        ...                   param2,
        ...                   param3):'''
        >>> result = regex_replace(regex, repl, text)
        >>> print(result)
        foodef

def regex_replace(regex, repl, text):
    r"""
    thin wrapper around re.sub
    regex_replace

    MULTILINE and DOTALL are on by default in all util_regex functions

    Args:
        regex (str): pattern to find
        repl (str): replace pattern with this
        text (str): text to modify

    Returns:
        str: modified text

    Example1:
        >>> # ENABLE_DOCTEST
        >>> from utool.util_regex import *  # NOQA
        >>> regex = r'\(.*\):'
        >>> repl = '(*args)'
        >>> text = '''def foo(param1,
        ...                   param2,
        ...                   param3):'''
        >>> result = regex_replace(regex, repl, text)
        >>> print(result)
        def foo(*args)

    Example2:
        >>> # ENABLE_DOCTEST
        >>> from utool.util_regex import *  # NOQA
        >>> import utool as ut
        >>> regex = ut.named_field_regex([('keyword', 'def'), ' ', ('funcname', '.*'), '\(.*\):'])
        >>> repl = ut.named_field_repl([('funcname',), ('keyword',)])
        >>> text = '''def foo(param1,
        ...                   param2,
        ...                   param3):'''
        >>> result = regex_replace(regex, repl, text)
        >>> print(result)
        foodef
    """
    return re.sub(regex, repl, text, **RE_KWARGS)