正则表达式匹配的MAC地址 [英] Regex matching MAC address
本文介绍了正则表达式匹配的MAC地址的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我正在尝试从该字符串中获取所有有效的MAC地址:
I'm trying to get all valid MAC addresses from this string:
00:1e:68:51:4f:a9 <-> 00:1a:8c:10:ad:30 9 540 8 336 17 876 90.457130000 198.0143
我已经尝试过这个和其他一些正则表达式:
I've tried this and a few other regexes:
^([0-9A-F]{2}[:]){5}([0-9A-F]{2})$
此处的正则表达式101:
https://regex101.com/r/kI5nI6/1
我不知道为什么我没有任何比赛.
I can't figure out why I'm not getting any matches.
推荐答案
-
您必须删除锚点
^
和$
您必须在字符集中添加
a-z
或使用(?i)
(i修饰符)You have to add
a-z
in your character set.. or make the searches case insensitive with(?i)
(i modifier)以下将起作用:
([0-9a-fA-F]{2}[:]){5}([0-9a-fA-F]{2})
请参见演示
这篇关于正则表达式匹配的MAC地址的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文