title: Python regex extract MAC addresses from string
body: <p>I need help writing a regular expression, using the python <code>re</code> engine to:</p>
  
  <ol>
  <li>Extract all MAC addresses from a text file</li>
  <li>Extract all strings with the following format: <code>foo bar ... MAC:ADDRESS ... baz bat \r\n</code></li>
  </ol>
  
  <p>Thanks in advance!</p>
  
  <p>I tried the following to extract MAC addresses, without luck:</p>
  
  <pre class="lang-python prettyprint-override"><code>import re
  p = re.compile(ur'((?:(\d{1,2}|[a-fA-F]{1,2}){2})(?::|-*)){6}')
  test_str = u"TEXT WITH SOME MAC ADDRESSES 00:24:17:b1:cc:cc TEXT CONTINUES WITH SOME MORE TEXT 20:89:86:9a:86:24"
  
  found = re.findall(p, test_str)
  for a in found:
      print a
  </code></pre>