常用正则匹配
作者:互联网
mac地址
/^[A-F0-9]{2}(-[A-F0-9]{2}){5}$|^[A-F0-9]{2}(:[A-F0-9]{2}){5}$/
Mac地址有两种:
58:E8:76:83:A2:C7
/^[A-Fa-f0-9]{1,2}\:[A-Fa-f0-9]{1,2}\:[A-Fa-f0-9]{1,2}\:[A-Fa-f0-9]{1,2}\:[A-Fa-f0-9]{1,2}\:[A-Fa-f0-9]{1,2}$/
58-E8-76-83-A2-C7
/^[A-Fa-f0-9]{1,2}\-[A-Fa-f0-9]{1,2}\-[A-Fa-f0-9]{1,2}\-[A-Fa-f0-9]{1,2}\-[A-Fa-f0-9]{1,2}\-[A-Fa-f0-9]{1,2}$/
简写后:
/^[A-F0-9]{2}(-[A-F0-9]{2}){5}$/
/^[A-F0-9]{2}(:[A-F0-9]{2}){5}$/
ip地址
/^(\d|[1-9]\d|1\d{2}|2[0-5][0-5])\.(\d|[1-9]\d|1\d{2}|2[0-5][0-5])\.(\d|[1-9]\d|1\d{2}|2[0-5][0-5])\.(\d|[1-9]\d|1\d{2}|2[0-5][0-5])$/
标签:f0,F0,常用,匹配,58,76,Fa,正则,A2 来源: https://blog.csdn.net/qq_28686911/article/details/118754060