常用正则表达式小记

记几类在网络上常用的正则表达式

IPv4

(25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9]?[0-9])\.(25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9]?[0-9])\.(25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9]?[0-9])\.(25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9]?[0-9])

IPv4/Mask

(25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9]?[0-9])\.(25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9]?[0-9])\.(25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9]?[0-9])\.(25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9]?[0-9])/(3[0-2]|[0-2]?[0-9])

域名

设置大小写不敏感,Unicode 域名需要先解码,Python 为例 domain.decode('idna').encode('utf-8)

((?=[a-z0-9-]{1,63}\.)(xn--)?[a-z0-9]+(-[a-z0-9]+)*\.)+[a-z]{2,63}

MAC

设置大小写不敏感

[0-9A-F]{2}([-:]?)(?:[0-9A-F]{2}\1){4}[0-9A-F]{2}

Email

[A-Z0-9._%+-]+@[A-Z0-9.-]+\.[A-Z]{2,}

posted @ 2019-08-04 22:55  RiwellAckerman  阅读(...)  评论(... 编辑 收藏