import re


def upper_to_under(var):
    """
    Insert underscore before upper case letter followed by lower case letter and lower case all sentence.
    """
    return re.sub('([a-z0-9])([A-Z])', r'\1_\2', re.sub('(.)([A-Z][a-z]+)', r'\1_\2', var)).lower()