def _digest_sub_groups(m, pattern_groups):
    """
    Reorganize regex groups internally.
    :param pattern_groups: ordered list of groups as they appear in RE
    :return: array only found item tuples:  (group, value, start, end)
    """
    count = 0
    slots = []
    glen = len(pattern_groups)
    for found in m.groups():
        if count > glen:
            raise Exception("Unexpected -- more slots found than groups in pattern.")
        slot_name = pattern_groups[count]
        slot = (slot_name, found, m.start(count + 1), m.end(count + 1))
        slots.append(slot)
        count += 1

    return slots