import re


def filter_cmd_list(cmd_list, regex_to_include=".*", regex_to_exclude=None, dict_key='label'):
    """Filter a list of Benchpress commands

    Parameters
    ----------
    cmd_list : list of dict
        The commands to filter.
    regex_to_include : str
        RegEx that match for inclusion.
    regex_to_exclude : str
        RegEx that match for exclusion.
    dict_key : str
        The dict-key in the command to search within.

    Returns
    -------
    new_cmd_list : list of dict
        New list of commands.
    """
    ret = []
    for cmd in cmd_list:
        if re.search(regex_to_include, cmd[dict_key]) is not None:
            if regex_to_exclude is None or re.search(regex_to_exclude, cmd[dict_key]) is None:
                ret.append(cmd.copy())
    return ret