Regex pattern
UUID Regex — free online tester
Strict UUID pattern — validates version (1–7) and variant nibbles so random hex strings don't pass.
The pattern
[0-9a-f]{8}-[0-9a-f]{4}-[1-7][0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}/giHow it works
A correct UUID has 32 hex digits laid out as 8-4-4-4-12. This regex goes further: it asserts that the version nibble (13th character) is 1–7 and the variant nibble (17th character) is 8, 9, a, or b — matching the IETF RFC 9562 spec. Case-insensitive so both lowercase and uppercase representations pass.
When to use it
- ▸Extract UUIDs from log files (especially structured / JSON logs)
- ▸Validate user input as a UUID before passing to a database
- ▸Find records by id in unstructured text
- ▸Pre-flight checks in URL routing
Tip
Add anchors (^ and $) to validate that the entire input is a UUID rather than just contains one.
Try it on this input
Session: 550e8400-e29b-41d4-a716-446655440000 (v4) User: 7d444840-9dc0-11d1-b245-5ffdce74fad2 (v1) Trace: 0188aa9b-1234-7abc-89ab-cccccccccccc (v7) Bulk: 6ba7b811-9dad-31d1-80b4-00c04fd430c8 (v3) Bad: 12345, abc-def, 550e8400-e29b-91d4-a716-446655440000 (v9, no such version)
What this pattern doesn't catch
- ⚠Does not match the Nil UUID 00000000-0000-0000-0000-000000000000 or Max UUID ff…
- ⚠Pre-RFC versions (v0, v8) are not matched — adjust the [1-7] class if needed
- ⚠Doesn't validate that the bytes match a specific implementation (e.g. v4 randomness)
More regex patterns
Email Regex
A practical email-validation regex that catches the 99% case without choking on every RFC edge case.
URL Regex
Extract every http(s) URL from a block of text — captures protocol, domain, path, query string, and fragment.
Phone Number Regex
Match US / Canada phone numbers in every common written format — with or without country code.
Date Regex (ISO 8601)
Match ISO 8601 dates (YYYY-MM-DD) and optionally times in any text — the format JSON APIs, databases, and logs use.
IPv4 Regex
Strictly match IPv4 addresses — rejects out-of-range octets like 256.0.0.1 that simpler patterns let through.
Credit Card Regex
Match credit-card numbers from major networks (Visa, Mastercard, Amex, Discover) for extraction or redaction.
Full Regex Tester →
Cheatsheet · pattern builder · cross-language translation · replace · explain · history
