Is there a simple way to intersect two strings? I did not find anything about that.
intersect["abcdEfgh","blahcdEzz"] (* "cdE" *)
By intersection, I mean the longest substring(s) that is(are) common to both strings.
Mathematica Stack Exchange is a question and answer site for users of Wolfram Mathematica. It only takes a minute to sign up.
Sign up to join this communityIs there a simple way to intersect two strings? I did not find anything about that.
intersect["abcdEfgh","blahcdEzz"] (* "cdE" *)
By intersection, I mean the longest substring(s) that is(are) common to both strings.
As porposed by @V.E. you should use LongestCommonSubsequence[s1,s2]
. Example from the documentation:
LongestCommonSubsequence[ "AAABBBBCCCCC", "CCCBBBAAABABA"]
(* AAAB *)