import re


def split_kwargs(kwargs_dict, prefix='shadow_'):
    """
    Splits dictionary into two new dicts by checking the keys for a given prefix. Those key-value pairs
     with the prefix will be added to a new dictionary with prefix removed from the keys.
    :param kwargs_dict: original dict to be checked and split. As dict
    :param prefix: prefix to search keys for. As string
    :return: copy of original dict with preficed keys removed, new dict based on prefixed keys
    """
    input_dict = kwargs_dict.copy()
    output_dict = {}
    shadow_dict = {}

    for k, v in input_dict.items():
        if bool(re.match(prefix + '.*', k)):  # find keys with prefix
            shadow_k = re.sub(prefix, '', k)  # remove prefix
            shadow_dict[shadow_k] = v
        else:
            output_dict[k] = v

    return output_dict, shadow_dict