RegexCalc Regex Engine

UUID v4 Regex Validator

A UUID version 4 pattern, pre-loaded in the tester. Below it, a table shows what it rejects and why, with the one-character changes that accept upper case or every UUID version.

Regular Expression JAVASCRIPT REGEX
/ / gm
Match Status
2 matches found
Pattern Valid
Recipes:
Test String
Extracted Matches

What this UUID pattern accepts and rejects

This pattern accepts version 4 UUIDs only: the third group must start with 4 and the fourth with 8, 9, a or b (the RFC 9562 variant). It is lower-case only, which is stricter than the standard.

Each input below was tested on its own against the pattern above when this page was built, with no flags, so ^ and $ anchor the whole value. Paste any of them into the tester to see the same result.

InputResultWhy it matters
550e8400-e29b-41d4-a716-446655440000MatchesA version 4 UUID.
550E8400-E29B-41D4-A716-446655440000No matchRejected: upper-case hex. RFC 9562 asks for case-insensitive comparison, so add the i flag unless you control every producer.
6ba7b810-9dad-11d1-80b4-00c04fd430c8No matchRejected: a version 1 UUID (time-based).
018f3f5e-1c2b-7d3a-9f4e-1a2b3c4d5e6fNo matchRejected: a version 7 UUID (time-ordered), now common for database keys. Widen the version digit to [1-8] to accept every version.
550e8400-e29b-41d4-c716-446655440000No matchRejected: variant c is not the RFC 9562 variant.
00000000-0000-0000-0000-000000000000No matchRejected: the nil UUID has no version.
550e8400e29b41d4a716446655440000No matchRejected: the hyphens are required.
{550e8400-e29b-41d4-a716-446655440000}No matchRejected: the braced form some Windows tools print. Strip the braces first.

More from RegexCalc

Guides

All tools →All 13 guides →

Frequently Asked Questions

Why does this UUID regex reject upper-case UUIDs?

Its character classes list lower-case hex only. RFC 9562 says UUIDs should be compared case-insensitively, so add the i flag unless every UUID you receive comes from a producer that writes lower case.

How do I accept UUID version 7, or every version?

Change the 4 that starts the third group to [1-8]. The versions differ only in that digit, so the widened pattern accepts versions 1 to 8 while still checking the variant digit.

Developer Sponsor / Partner
Copied to clipboard!