import re


def normalize(string, force_underscore=False):
    """Replaces invalid characters with an underscore character

    string.normalize will add an "_" character in front of the returned string
    if the input starts with an intiger

    Args:
        string(str): A string to normalize
        force_underscore(bool): Convert hyphens to underscores
    Returns:
        str: Normalized string

    Note:
        Invalid characters are punctuation and most of the symbols.
    """

    string = str(string)
    if re.match("^[0-9]", string):
        string = "_" + string

    if force_underscore:
        token = "[^A-Za-z0-9_]"
    else:
        token = "[^A-Za-z0-9_-]"

    return re.sub(token, "_", str(string))