import difflib


def find_regular_matches(ops):
    """
    Find the set of regular (non-shift) matches from the list of operations.

    "ops" is the list of triples as returned by greedy_matching().
    """
    matches1 = sorted(m for m in ops if m[0] != -1 and m[1] != -1)
    matches2 = sorted(matches1, key=lambda match: match[1])
    # Search for the longest common subsequence in characters
    # Expand "string" matches into "character" matches
    char_matches1 = [(m, i) for m in matches1 for i in range(len(m[2]))]
    char_matches2 = [(m, i) for m in matches2 for i in range(len(m[2]))]
    sm = difflib.SequenceMatcher(None, char_matches1, char_matches2, autojunk=False)
    return {m for a, _, size in sm.get_matching_blocks()
            for m, _ in char_matches1[a:a + size]}