def econfigstr_hole(econfigstr, corelevel, highesunoccp, htype='valence'):
    """
    # '1s2 | 2s2' , '1s2' , '2p0' -> '1s1 | 2s2 2p1'

    :param: string
    :param: string
    :param: string

    :return: string
    """
    corestates = econfigstr.split()
    hoc = int(highesunoccp[2:])
    if htype == 'valence':
        new_highocc = str(hoc + 1)
    elif hoc == 0:
        highesunoccp = ''
        new_highocc = ''
    else:
        new_highocc = str(hoc)
    new_econfig = ''
    added = False
    for state in corestates:
        if state == corelevel:
            occ = int(state[2:])
            new_occ = occ - 1
            state = state[:2] + str(new_occ)
        if state == highesunoccp:
            added = True
            state = highesunoccp[:2] + str(new_highocc)
        new_econfig = new_econfig + state + ' '
    if not added:
        new_econfig = new_econfig + highesunoccp[:2] + str(new_highocc)
    return new_econfig.rstrip(' ')
