title: Python Regular Expression. Matching once or twice pattern
body: <p>I have a bunch of lines in a file with either one or two occurences of same pattern (id=): </p>
  
  <pre><code>Linetype1 : ...id=1234...id=4321...value=5678... # "..." means whatever
  Linetype2 : ...id=7890...value=8765
  </code></pre>
  
  <p>I thought I could write such a regex to grep all my ids and associated values:</p>
  
  <pre><code>&gt;&gt;&gt; l="...id=1234...id=4321...value=5678...\n...id=7890...value=8765\n"
  &gt;&gt;&gt; ret = re.findall('(id=[0-9]+).*?(id=[0-9]+)*.*?(value=[0-9]+)',l)
  [('id=1234', '', 'value=5678'), ('id=7890', '', 'value=8765')]
  </code></pre>
  
  <p>I can't get the second "id=4321" part.
  This looks very strange to me since I use the non-greedy .*? between first id=[0-9]+ and second.</p>