import re


def format_id(s):
    """Formats the given string so it can be used as an ID.

    Example:

    >>> format_id('name.surname')
    name-surname
    """
    if not s:
        return '_'
    return re.sub(r'[^-a-zA-Z0-9_]', '-', s)