title: Find elements between two tags in a list
body: <p>Language: Python 3.4
  OS: Windows 8.1</p>
  
  <p>I have some lists like the following: </p>
  
  <pre><code>a = ['text1', 'text2', 'text3','text4','text5']
  b = ['text1', 'text2', 'text3','text4','New_element', 'text5']
  </code></pre>
  
  <p>What is the simplest way to find the elements between two tags in a list?</p>
  
  <p>I want to be able to get it even if the lists and tags have variable number of elements or variable length. </p>
  
  <p>Ex: get elements between text1 and text4 or text1 or text5, etc. Or get the elements between text1 and text5 that has longer length. </p>
  
  <p>I tried using regular expressions like: </p>
  
  <pre><code>re.findall(r'text1(.*?)text5', a)
  </code></pre>
  
  <p>This will give me an error I guess because you can only use this in a string but not lists. </p>