def regex_groups_match(regex, lhs, rhs):
    """Do two strings match modulo a regular expression?

    Args:
        regex: regular expression
        lhs: LHS string
        rhs: RHS string
    Returns:
        A boolean indicating match.
    """
    lhs_match = regex.search(lhs)
    if lhs_match:
        rhs_match = regex.search(rhs)
        if rhs_match and lhs_match.groups() == rhs_match.groups():
            return True
    return False