r"""
    References:
        http://stackoverflow.com/questions/1175208/convert-camelcase

    Example:
        >>> # ENABLE_DOCTEST
        >>> from utool.util_str import *  # NOQA
        >>> camelcase_str = 'UnderscoreFuncname'
        >>> camel_case_str = to_underscore_case(camelcase_str)
        >>> result = ('underscore_str = %s' % (str(camel_case_str),))
        >>> print(result)
        underscore_str = underscore_funcname

def to_underscore_case(camelcase_str):
    r"""
    References:
        http://stackoverflow.com/questions/1175208/convert-camelcase

    Example:
        >>> # ENABLE_DOCTEST
        >>> from utool.util_str import *  # NOQA
        >>> camelcase_str = 'UnderscoreFuncname'
        >>> camel_case_str = to_underscore_case(camelcase_str)
        >>> result = ('underscore_str = %s' % (str(camel_case_str),))
        >>> print(result)
        underscore_str = underscore_funcname
    """
    s1 = re.sub('(.)([A-Z][a-z]+)', r'\1_\2', camelcase_str)
    return re.sub('([a-z0-9])([A-Z])', r'\1_\2', s1).lower()