title: Search for a pattern in a list of strings - Python
body: <p>I have a list of strings containing filenames such as,</p>
  
  <pre><code>file_names = ['filei.txt','filej.txt','filek.txt','file2i.txt','file2j.txt','file2k.txt','file3i.txt','file3j.txt','file3k.txt']
  </code></pre>
  
  <p>I then remove the <code>.txt</code> extension using: </p>
  
  <pre><code>extension = os.path.commonprefix([n[::-1] for n in file_names])[::-1]
  
  file_names_strip = [n[:-len(extension)] for n in file_names]
  </code></pre>
  
  <p>And then return the last character of each string in the list <code>file_names_strip</code>:</p>
  
  <pre><code>h = [n[-1:] for n in file_names_strip]
  </code></pre>
  
  <p>Which gives <code>h = ['i', 'j', 'k', 'i', 'j', 'k', 'i', 'j', 'k']</code></p>
  
  <p>How can i test for a pattern of strings in <code>h</code>? So if <code>i</code>,<code>j</code>,<code>k</code> occur sequentially it would return True and False if not. I need to know this because not all file names are formatted like they are in <code>file_names</code>.</p>
  
  <p>So:</p>
  
  <pre><code>test_ijk_pattern(h) = True
  
  no_pattern = ['1','2','3','1','2','3','1','2','3']
  
  test_ijk_pattern(no_pattern) = False
  </code></pre>