def trim_characters(string):
    """Remove leading and trailing generic characters from a string.

    :param string:
        Value that will be trimmed.
        Characters that will be removed include: '.', ',', ';', '-', '_'.
    :type string: str
    :returns: Edited value.
    :rtype: str
    """
    generic_characters = set(['.', ',', ';', '-', '_'])
    if len(string) > 0:
        value1 = True
        while value1:
            if string[-1] in generic_characters:
                string = string[:-1]
            else:
                value1 = False
        value2 = True
        while value2:
            if string[0] in generic_characters:
                string = string[1:]
            else:
                value2 = False
    return string
