title: Matching an expression over multiple lines
body: <p>I'm working on extracting the pattern <code>def ([^\s]+)\([^\.]*\)</code> in Python. However, when I have multiline input, only the first occurrence is obtained. I have specific the <code>re.MULTILINE</code> option on my Python regular expression but still to no avail. Lets say I have the following input:</p>
  
  <pre><code>def a():
      pass
  b()
  def b():
      pass
  </code></pre>
  
  <p>My regular expression only extracts the 'a' and doesn't continue and extract 'b'. The code I'm using is:</p>
  
  <pre><code>self.function_re = re.compile(r'def (\S+)\([^\.]*\)', re.MULTILINE)
  print(self.function_re.findall(self.code))
  </code></pre>
  
  <p>Which outputs <code>['a']</code>.</p>