import re


def sub_args(args, args_regex, sub):
    """Substitute all instances of args_regex in args.

    Works if args is a str, list, tuple, or dict. All values replaced with
    re.sub. If args is dict, only the values, not the keys, are replaced.

    :args:       str, list, tuple, or dict
    :args_regex: r'' expression to replace with
    :sub:        string to replace regex with
    :returns:    args, but with all instances of regex replaced

    """
    step_regex = re.compile(args_regex)
    if isinstance(args, str):
        return step_regex.sub(sub, args)
    elif isinstance(args, (tuple, list)):
        step_args = []
        for arg in args:
            step_args.append(step_regex.sub(sub, arg))
        return tuple(step_args)
    elif isinstance(args, dict):
        step_args = {}
        for k, v in args.items():
            step_args[k] = step_regex.sub(sub, v)
        return step_args