I need help writing a regular expression, using the python re engine to:
- Extract all MAC addresses from a text file
- Extract all strings with the following format:
foo bar ... MAC:ADDRESS ... baz bat \r\n
Thanks in advance!
I tried the following to extract MAC addresses, without luck:
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