Regexdrill

Level 3: Real-world validation Exercise 38 of 70 Free

MAC addresses

A regex exercise from Regexdrill. Solve it with a pattern box with live highlighting in your browser, checked against hidden test strings, and it is checked the moment you submit.

The task

The whole line must match. Match a MAC address: six pairs of hex digits (0 to 9, a to f, either case) separated by colons, like 00:1A:2b:3C:4d:5E.

What this exercise teaches

(?:[0-9A-Fa-f]{2}:){5}[0-9A-Fa-f]{2} counts the pairs exactly. \w{2} would let g through, and a class like [0-9A-Fa-f:]{17} would accept the colons in the wrong places.

A hint if you get stuck

Repeat a group of two hex digits and a colon five times, then add the last pair without a colon.

Try it now, free, no account needed

Every exercise on Regexdrill is free to try. Open it on the practice page, solve it, and get instant feedback with a hint. A free account adds the worked solution; Pro adds timed mode and the certificate.

Open this exercise

More exercises in Real-world validation