title: python regex match line if exist or not
body: <p>I have a little problem with a regex.</p>
  
  <p>Here is a sample of the text to parse :</p>
  
  <pre><code>output = """
  country : USA
  zzzzzzz
  continent : Americ
  eeeeeee
  ------
  country : China
  zzzzzzz
  continent : Asia
  planet : Earth
  -------
  country : Izbud
  zzzzzzz
  continent : Gladiora
  zzzzzzz
  zzzzzzz
  planet : Mars
  """
  </code></pre>
  
  <p>I want to parse this and return the country, the continent and eventually the planet.</p>
  
  <p>So i did a regex :</p>
  
  <pre><code>results = re.findall(
      r"""(?mx)
          ^country\s:\s*(.+)\s
          (?:^.+\s)*?
          ^continent\s:\s*(.+)\s
          (?:^.+\s)*?
          (?:^planet\s:\s*(.+)\s)*?
  """,output)
  </code></pre>
  
  <p>but the return is :</p>
  
  <pre><code>[('USA', 'Americ', ''), ('China', 'Asia', ''), ('Izbud', 'Gladiora', '')]
  </code></pre>
  
  <p>And I don't know where my regex is wrong ?</p>
  
  <p>If anyone has an idea,
  thanks.</p>