Wolfram Language & System 11.0 (2016)|Legacy Documentation

This is documentation for an earlier version of the Wolfram Language.View current documentation (Version 11.2)

LongestCommonSubsequencePositions

LongestCommonSubsequencePositions[s1,s2]
finds the longest contiguous subsequence of elements common to the strings or lists s1 and s2 and returns their positions {pos1,pos2} in s1 and s2.

Details and OptionsDetails and Options

  • For lists si, Take[si,posi] returns the longest common subsequence. For strings si, StringTake[si,posi] returns the longest common contiguous substring.
  • If there are several common subsequences of the same length, LongestCommonSubsequencePositions returns the position of the one that appears earliest in s1.
  • For strings, setting the option IgnoreCase->True makes LongestCommonSubsequencePositions treat lowercase and uppercase letters as equivalent, and returns the form of common subsequence that occurs in s1.

ExamplesExamplesopen allclose all

Basic Examples  (2)Basic Examples  (2)

Find the longest contiguous subsequence common to two strings:

In[1]:=
Click for copyable input
Out[1]=

Find the longest contiguous subsequence common to two lists:

In[1]:=
Click for copyable input
Out[1]=
Introduced in 2015
(10.2)