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
Try this, working perfect..
A MAC address is a unique identifier assigned to most network adapters or network interface cards (NICs) by the manufacturer for identification, IEEE 802 standards use 48 bites or 6 bytes to represent a MAC address. This format gives 281,474,976,710,656 possible unique MAC addresses.
IEEE 802 standards define 3 commonly used formats to print a MAC address in hexadecimal digits:
Six groups of two hexadecimal digits separated by hyphens (-), like 01-23-45-67-89-ab
Six groups of two hexadecimal digits separated by colons (:), like 01:23:45:67:89:ab
Three groups of four hexadecimal digits separated by dots (.), like 0123.4567.89ab
public boolean macValidate(String mac) {
Pattern p = Pattern.compile("^([0-9A-Fa-f]{2}[:-]){5}([0-9A-Fa-f]{2})$");
Matcher m = p.matcher(mac);
return m.find();
}