Overview:
• The get_matching_blocks() method of the SequenceMatcher class returns the starting index and the length of each matching block from two sequences that are non-overlapping.
• The details of the matching blocks are returned as a list of tuples.
Example:
|
# Example Python program that returns the matching # Create a SequenceMatcher object # Set sequence1 # Set sequence2 # Find the matching blocks print("Sequence one:") print("Matching non-overlapping sub-sequences:") |
Output:
|
[Match(a=0, b=0, size=1), Match(a=1, b=6, size=3), Match(a=10, b=9, size=8), Match(a=19, b=17, size=1), Match(a=21, b=18, size=1), Match(a=22, b=32, size=2), Match(a=25, b=35, size=3), Match(a=41, b=38, size=4), Match(a=46, b=43, size=0)]
|