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
Why so much code? Here is how you can "normalize" your mac address:
mac.replaceAll("[^a-fA-F0-9]", "");
And here is a way to validate it:
public boolean validate(String mac) { Pattern p = Pattern.compile("^([a-fA-F0-9][:-]){5}[a-fA-F0-9][:-]$"); Matcher m = p.matcher(mac); return m.find(); }