title: how to get the shortest matching with python (complex non-greedy pattern)
body: <p>I am trying to get the shortest matching of the pattern <code>'''.*?''' is a [[.*?]]</code> for sentences such as </p>
  
  <pre><code>'''fermentation starter''' is a preparation to assist the beginning of the [[fermentation (biochemistry)|fermentation]]. A '''starter culture''' is a [[microbiological culture]]
  </code></pre>
  
  <p>which contains the target string</p>
  
  <pre><code> '''starter culture''' is a [[microbiological culture]]
  </code></pre>
  
  <p>The idea is to get the later string. To do so, I am using the following python code:</p>
  
  <pre><code>regex = re.compile("'''.*?''' is a \[\[.*?\]\]")
  re.findall(regex, line)
  </code></pre>
  
  <p>However, I am getting the full sentence instead of the shortest pattern. Note that I have added '?' after the qualifier to make the match perform in a non-greedy fashion. Also I can solve it using </p>
  
  <pre><code>re.findall(regex, line[30:])
  </code></pre>
  
  <p>in order to escape the first occurrence of <code>'''.*?'''</code>, but I am looking for a more natural solution.</p>