title: Regex matching between two strings?
body: <p>I can't seem to find a way to extract all comments like in following example.</p>
  
  <pre><code>&gt;&gt;&gt; import re
  &gt;&gt;&gt; string = '''
  ... &lt;!-- one 
  ... --&gt;
  ... &lt;!-- two -- -- --&gt;
  ... &lt;!-- three --&gt;
  ... '''
  &gt;&gt;&gt; m = re.findall ( '&lt;!--([^\(--&gt;)]+)--&gt;', string, re.MULTILINE)
  &gt;&gt;&gt; m
  [' one \n', ' three ']
  </code></pre>
  
  <p>block with <code>two -- --</code> is not matched most likely because of bad regex. Can someone please point me in right direction how to extract matches between two strings. </p>
  
  <hr>
  
  <p>Hi I've tested what you guys suggested in comments.... here is working solution with little upgrade.</p>
  
  <pre><code>&gt;&gt;&gt; m = re.findall ( '&lt;!--(.*?)--&gt;', string, re.MULTILINE)
  &gt;&gt;&gt; m
  [' two -- -- ', ' three ']
  &gt;&gt;&gt; m = re.findall ( '&lt;!--(.*\n?)--&gt;', string, re.MULTILINE)
  &gt;&gt;&gt; m
  [' one \n', ' two -- -- ', ' three ']
  </code></pre>
  
  <p>thanks!</p>