Python 正则表达式匹配 MAC 地址
import re
string = 'mac:d4:3a:2e:f8:bf:b2 mac:a2:1f:2a:c3:b1' pattern = r"([0-9a-fA-F]{2}:){5}[0-9a-fA-F]{2}" matches = re.findall(pattern, string)
print(matches)
Output: ['d4:3a:2e:f8:bf:b2', 'a2:1f:2a:c3:b1']
原文地址: https://www.cveoy.top/t/topic/n8FZ 著作权归作者所有。请勿转载和采集!