def _count_multiflag_in_argv(args, short, long, eliminate=False):
    """
    Match flags in `argvs` list, in short/long form, and optionally remove them.

    :param eliminate:
        If true, returned flags will have those matching, removed.
    :return:
        the 2-tuple (num-of-matches, new-args) where `new-args` possibly
        have flags missing.
    """
    import re
    long = '--%s' % long
    nmatches = 0
    new_args = []
    for flag in args:
        if flag == long:
            nmatches += 1
            if eliminate:
                continue
        elif re.match('^-[a-z]+', flag, re.I):
            nmatches += flag.count(short)
            if eliminate:
                flag = flag.replace(short, '')
                if flag == '-':
                    continue
        new_args.append(flag)
    return nmatches, new_args
