Different MAC Addresses Regex

后端 未结 7 825
旧时难觅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:20

    MAC addresses can be 6 or 20 bytes (infiniband)

    The correct regexp assuming the separator is : is

    ^([0-9A-Fa-f]{2}:){5}(([0-9A-Fa-f]{2}:){14})?([0-9A-Fa-f]{2})$
    

    We match 5 times XX: optionally we match another 14 times XX: and we match XX

提交回复
热议问题