日期:2014-05-17  浏览次数:20725 次

求正则匹配CPU,MAC地址?
1、CPU号由32位大写字母与数字组成 

样式CPU:BFEBFBFF 0001067A 00000000 00000000

2、MAC地址由大写字母A到F或数字组成,

样式00:50:56:C0:00:08

------解决方案--------------------
cpu:
/CPU:([A-Z0-9]{8}\s*){4}/
mac:
/([A-F0-9]{2}:?){4}/
------解决方案--------------------
cpu [a-zA-Z0-9]{8}([ ][a-zA-Z0-9]{8}){3}

mac [A-Z0-9]{2}(:[A-Z0-9]{2}){5}
------解决方案--------------------
探讨

cpu [a-zA-Z0-9]{8}([ ][a-zA-Z0-9]{8}){3}

mac [A-Z0-9]{2}(:[A-Z0-9]{2}){5}

------解决方案--------------------
探讨

引用:

cpu [a-zA-Z0-9]{8}([ ][a-zA-Z0-9]{8}){3}

mac [A-Z0-9]{2}(:[A-Z0-9]{2}){5}

cpu [a-zA-Z0-9]{8}([ ][a-zA-Z0-9]{8}){3}

mac [A-F0-9]{2}(:[A-F0-9]{2}){5}

------解决方案--------------------
CPU: ^([A-Z0-9]{8}\s){3}[A-Z0-9]{8}$
mac: ^[A-F0-9]{2}(:[A-F0-9]{2}){5}$