title: Python split by regular expression?
body: <p>Okay, in python, I am extracting emails from a string like so:</p>
  
  <pre><code>split = re.split(" ", string)
  emails = []
  
  pattern = re.compile("^[a-zA-Z0-9_\.-]+@[a-zA-Z0-9-]+.[a-zA-Z0-9-\.]+$");
  
  for bit in split:
      result = pattern.match(bit)
  
      if(result != None):
          emails.append(bit)
  </code></pre>
  
  <p>And this works, as long as there is a space in between the emails. But this might not always be the case. For example:</p>
  
  <p><code>Hello, foo@foo.com</code></p>
  
  <p>would return:</p>
  
  <p><code>foo@foo.com</code></p>
  
  <p>but, take the following string:</p>
  
  <p><code>I know my best friend mailto:foo@foo.com!</code></p>
  
  <p>This would return <code>null</code>. So the question is: how can I make it so that a regex is the delimiter to split? I would want to get</p>
  
  <p><code>foo@foo.com</code></p>
  
  <p>in all cases, regardless of puncuation next to it. Is this possible in python?</p>
  
  <p><em>By "splitting by regex" I mean that if the program encounters the pattern in a string, it will extract that part and put it into a list.</em></p>