import re


def modify_vars(vars_orig, var_modifiers):
    """Return a copy of `vars_orig` modified according to `var_modifiers`.

    Parameters
    ----------
    vars_orig : list of str
        A list of variable names.
    var_modifiers : list of str or None, optional
        A list of variable modifiers. Each variable modifier is a string
        either "+var_name" or "-var_name".
        If `var_modifiers` has "+var_name", then "var_name" will be added
        to the result.
        If `var_modifiers` has "-var_name", then "var_name" will be removed
        from  the result.
        If `var_modifiers` is None, then a simple copy of `vars_orig` will be
        returned.
        Default: None.

    Returns
    -------
    list of str
        A copy of `vars_orig` modified according to `var_modifiers`.
    """

    if var_modifiers is None:
        return vars_orig

    result = vars_orig[:]

    regexp = re.compile(r'([+-])(.*)')

    for vm in var_modifiers:

        res = regexp.match(vm)
        if not res:
            raise ValueError('Failed to parse column modifier %s' % vm)

        mod = res.group(1)
        val = res.group(2)

        if mod == '+':
            if val not in result:
                result.append(val)
        else:
            result.remove(val)

    return result