Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- def get_real_mac(sentence):
- # Here, I assume that MAC address is seperated by a colon, or by a dash, but not by both.
- colon_pattern = r'[0-9abcde]{2}:[0-9ABCDEF]{2}:[0-9ABCDEF]{2}:[0-9ABCDEF]{2}:[0-9ABCDEF]{2}:[0-9ABCDEF]{2}'
- colon_matches = re.findall(colon_pattern, sentence, re.IGNORECASE)
- dash_pattern = re.sub(r':', r'-', colon_pattern)
- dash_matches = re.findall(dash_pattern, sentence, re.IGNORECASE)
- rt_list = colon_matches + dash_matches
- if rt_list:
- return rt_list[0]
- return None
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement