Regex to Match a UUID
Copy the pattern, paste your text below, and see every UUID it finds. Below the tester: the 8-4-4-4-12 layout and how to make it case- or version-strict.
What this pattern matches
This matches a canonical UUID: five hex groups of 8, 4, 4, 4, and 12 characters separated by hyphens. It accepts every version (v1–v8) and both letter cases.
How it works, part by part
[0-9a-fA-F]{8} — the first group of eight hex digits.
-[0-9a-fA-F]{4} — three middle groups of four hex digits each.
-[0-9a-fA-F]{12} — the final group of twelve hex digits.
Version-strict matching
To require a specific version, pin the first digit of the third group — for example -4[0-9a-fA-F]{3}- matches only UUID v4.
FAQ
Does it match all UUID versions?
Yes. It accepts any hex in the version and variant positions, covering v1 through v8.
How do I match only UUID v4?
Replace the third group with 4[0-9a-fA-F]{3} to require the version-4 marker.
Is it case-insensitive?
Yes. The class includes both a-f and A-F, so upper and lowercase UUIDs both match.