I have two strings. For the sake of the example they are set like this:
string1=\"test toast\"
string2=\"test test\"
What I want is to find
If using other languages, how about python:
cmnstr() { python -c "from difflib import SequenceMatcher
s1, s2 = ('''$1''', '''$2''')
m = SequenceMatcher(None,s1,s2).find_longest_match(0,len(s1),0,len(s2))
if m.a == 0: print(s1[m.a: m.a+m.size])"
}
$ cmnstr x y
$ cmnstr asdfas asd
asd
(h/t to @RickardSjogren's answer to stack overflow 18715688)