I'm trying to use regex to extract a MAC address from a string. The regex that I've used should work.
raw_mac_string
returns a ether <mac_address>
What I'm trying to do is get original_mac
to extract the <mac_address>
from raw_mac_string
.
original_mac
when run, keeps giving error: AttributeError: 'NoneType' object has no attribute 'group'
Thanks for the help
I guess my question is, how can I extract the MAC address from a string that contains other text as well?
#get original mac address
global original_mac
raw_mac_string = subprocess.check_output('ifconfig en0 | grep ether | awk "{print $2}"', shell=True)
print "raw_mac"+raw_mac_string
original_mac = re.match(r"/^(?:[[:xdigit:]]{2}([-:]))(?:[[:xdigit:]]{2}\1){4}[[:xdigit:]]{2}$/", raw_mac_string).group()