Different MAC Addresses Regex

后端 未结 7 828
旧时难觅i
旧时难觅i 2021-01-06 08:30

What is the correct regular expression for matching MAC addresses ? I googled about that but, most of questions and answers are incomplete. They only provide a regular expre

7条回答
  •  [愿得一人]
    2021-01-06 09:21

    Below Regex Pattern will help to manage all kinds of the above listed patterns

    "([MACmac]?){1}([:.-]?){1}(([0-9A-Fa-f]{2,3}[:.-]?){4,6})"
    

    here at end i added {4,6} because some pattern as requested below is expecting the group of 3 for 4 time. else if you are looking ONLY for the default on which is usually group of 2 characters 6 times then you can use the below one.

    "([MACmac]?){1}([:.-]?){1}(([0-9A-Fa-f]{2}[:.-]?){6})"
    

    hope this helps all.

提交回复
热议问题