gettoolz.app

UUID regex

Thirty-two hex digits in 8-4-4-4-12 groups, with a version digit from 1 to 8 and the RFC 9562 variant bits (8, 9, a or b). Copy the pattern, with 4 inputs it accepts and 5 it rejects, each checked against it at build time.

Part of developer tools.

Pattern^[0-9a-f]{8}-[0-9a-f]{4}-[1-8][0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$
JavaScript literal/^[0-9a-f]{8}-[0-9a-f]{4}-[1-8][0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$/i

What the uuid regex accepts and rejects

Each result below is the output of the pattern itself, run on the input when this page was built — not a claim copied next to it. A wrong verdict stops the build.

Inputs tested against the UUID regex
InputResultWhy
123e4567-e89b-12d3-a456-426614174000Passesversion 1, time-based
550e8400-e29b-41d4-a716-446655440000Passesversion 4, random
01890a5d-ac96-774b-bcce-b302099a8057Passesversion 7, time-ordered
F47AC10B-58CC-4372-A567-0E02B2C3D479Passesupper case, thanks to the i flag
00000000-0000-0000-0000-000000000000Failsthe nil UUID has version 0
550e8400e29b41d4a716446655440000Failsno hyphens
550e8400-e29b-41d4-c716-446655440000Failsvariant c is not the RFC variant
{550e8400-e29b-41d4-a716-446655440000}Failsbraces, as Windows writes GUIDs
550e8400-e29b-41d4-a716-44665544000gFailsg is not a hex digit

Limits

  • The nil UUID (all zeros) and the max UUID (all f) are valid values in RFC 9562 but carry no version, so they are refused. Accept them explicitly if your data uses them as sentinels.
  • Braced and hyphen-less forms are refused. Strip braces and normalise the case before storing, rather than widening the pattern.

Try it on your own input

Open this pattern in the regex tester with every example above on its own line. The link adds the g and m flags so that ^ and $ hold per line and every line is tested: the highlighted lines are the ones marked as passing here. Paste your own data in place of the examples — it is matched in your browser and never uploaded.

Other common regexes

Or open the regex tester empty and bring your own pattern.