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 exerciseMore exercises in Real-world validation
- US ZIP and ZIP+4Free
- US phone number formatsFree
- Dates YYYY-MM-DDFree
- 24-hour times HH:MMFree
- 12-hour times with AM or PMFree
- Simple email addressesFree
- Hex colorsFree
- IPv4 addresses, 0 to 255Free
- URL slugsFree
- SKU codesFree
- Currency amounts with commasFree
- Semantic versionsFree
- MAC addressesFree
- Percentages from 0 to 100Free