def tag2version(ver):
    """convert a tag to a version.

    Here are some examples:
    >>> tag2version("1-2")
    '1-2'
    >>> tag2version("R1-2")
    '1-2'
    >>> tag2version("R-1-2")
    '1-2'
    >>> tag2version("seq-1-2")
    '1-2'
    >>> tag2version("head")
    'head'
    >>> tag2version("")
    ''
    """
    if not ver:
        return ver
    mode = 0
    for i in range(len(ver)):
        if mode == 0:
            if ver[i].isalpha():
                continue
            mode = 1
        if mode == 1:
            if ver[i] == '-' or ver[i] == '_':
                mode = 2
                continue
            mode = 2
        if mode == 2:
            if ver[i].isdigit():
                return ver[i:]
            return ver
    return ver
