I would like to find common string between: strings_list = ['PS1 123456 Test', 'PS1 758922 Test', 'PS1 978242 Test']
The following code returns only the first part "PS1 1", I would imagine the result is "PS1 Test". Could you help me, is it possible to obtain using SequenceMatcher? Thank you in advance!
def findCommonStr(strings_list: list) -> str:
common_str = strings_list[0]
for i in range(1, n):
match = SequenceMatcher(None, common_str, strings_list[i]).get_matching_blocks()[0]
common_str = common_str[match.b: match.b + match.size]
common_str = common_str.strip()
return common_str