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)


finds the longest sequence of contiguous or disjoint elements common to the strings or lists s1 and s2.

Details and OptionsDetails and Options

  • LongestCommonSequence returns the longest common sequence with disjoint pieces concatenated.
  • If there are several common subsequences of the same length, LongestCommonSequence returns the one that begins earliest in s1.
  • For strings, setting the option IgnoreCase->True makes LongestCommonSequence treat lowercase and uppercase letters as equivalent, and return the form of common sequence that occurs in s1.

ExamplesExamplesopen allclose all

Basic Examples  (1)Basic Examples  (1)

Find the longest noncontiguous sequence common to two strings:

Click for copyable input

Find the longest noncontiguous sequence common to two lists:

Click for copyable input
Introduced in 2008