# Intersecting two strings

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.

• reference.wolfram.com/language/ref/… – V.E. Dec 16 '17 at 23:31
• @V.E. Perfect. Feel free to write an answer for completeness... – anderstood Dec 16 '17 at 23:36
• Just one click on V.E.'s hint gives the answer... – Ulrich Neumann Dec 17 '17 at 12:34
• @UlrichNeumann Turning the comment into an answer allows me to accept it, and hence remove this question for the unanswered list. – anderstood Dec 17 '17 at 13:05
• @ anderstood: I got it! – Ulrich Neumann Dec 17 '17 at 13:28

As porposed by @V.E. you should use LongestCommonSubsequence[s1,s2]. Example from the documentation:
LongestCommonSubsequence[ "AAABBBBCCCCC", "CCCBBBAAABABA"]