title: How can I detect common substrings in a list of strings
body: <p>Given a set of strings, for example:</p>
  
  <pre><code>EFgreen
  EFgrey
  EntireS1
  EntireS2
  J27RedP1
  J27GreenP1
  J27RedP2
  J27GreenP2
  JournalP1Black
  JournalP1Blue
  JournalP1Green
  JournalP1Red
  JournalP2Black
  JournalP2Blue
  JournalP2Green
  </code></pre>
  
  <p>I want to be able to detect that these are three sets of files:</p>
  
  <ul>
  <li>EntireS[1,2]</li>
  <li>J27[Red,Green]P[1,2]</li>
  <li>JournalP[1,2][Red,Green,Blue]</li>
  </ul>
  
  <p>Are there any known ways of approaching this problem - any published papers I can read on this?</p>
  
  <p>The approach I am considering is for each string look at all other strings and find the common characters and where differing characters are, trying to find sets of strings that have the most in common, but I fear that this is not very efficient and may give false positives.</p>
  
  <p>Note that this is not the same as <a href="https://stackoverflow.com/questions/1185016/how-do-i-detect-groups-of-common-strings-in-filenames">'How do I detect groups of common strings in filenames'</a> because that assumes that a string will always have a series of digits following it.</p>