title: Why is re.sub is not replacing string with empty string
body: <p>I can't understand pythons re.sub behavior.  I want to replace an entire multi line string with nothing.  I want an empty string back:</p>
  
  <pre><code>#!/usr/bin/python
  
  import re
  
  
  if __name__ == "__main__":
      data = """hello
  world 
  good 
  day
  """
  
      textarea = re.sub( '.*', '', data)
      print "processed '%s'" % textarea
  
      textarea = re.sub( '.*', '', data, flags=re.MULTILINE)
      print "processed '%s'" % textarea
  </code></pre>
  
  <p>The above code, at least on my machine does NOT output the following:</p>
  
  <pre><code>processed ''
  </code></pre>
  
  <p>This is for both cases, multiline/non-multiline.  Instead the single quotes are spread across multiple lines.  Why is this so?</p>
  
  <p>What I really want to do is delete empty lines ( lines containing only zero or more spaces) from a multiline string, and I believe the above example is the issue.</p>
  
  <p>Thanks.</p>
  
  <p><strong>ANSWER:</strong></p>
  
  <p>As others pointed out. MULTILINE was confusing me. To answer the original question, instead of just my desire, the dot was not matching the newline, hence everything was getting replaced with an empty string, except the newlines in the original string were left alone.</p>
  
  <p>By adding the re.DOTALL flag to the above example gave the expected behavior of an empty string.</p>