Regexdrill

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

UUIDs

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 lowercase UUID: five groups of hex digits (0 to 9 and a to f) with lengths 8, 4, 4, 4 and 12, separated by hyphens.

What this exercise teaches

[0-9a-f]{8}(?:-[0-9a-f]{4}){3}-[0-9a-f]{12} fixes every group length and hyphen position. A single class with the hyphen in it, repeated 36 times, would accept hyphens anywhere.

A hint if you get stuck

Spell the group lengths out with counted repeats. The three middle groups have the same shape, so a counted group can cover them.

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