Data & Formatting · In-Browser Regular Expression Lab
UUID v4 Regex — Validate 128-bit RFC 4122 Canonical UUIDs
Strictly matches version 4 UUIDs with 36 canonical characters including hyphens and version bit 4.
Flags:
//none
Match Found
Load Sample:
Match Inspection & Details1 match
Match #1:c9bf9e57-1685-4c89-bafb-ff5af830be8a
Test Samples Verification Matrix
Expected Valid Samples (Should Match)
c9bf9e57-1685-4c89-bafb-ff5af830be8a Pass
550e8400-e29b-41d4-a716-446655440000 Pass
Expected Invalid Samples (Must Reject)
c9bf9e57-1685-3c89-bafb-ff5af830be8a Rejected (Pass)
not-a-uuid Rejected (Pass)
550e8400-e29b-41d4-a716-44665544000 Rejected (Pass)
Code Implementation Generator
// JavaScript / TypeScript (ES6+)
const pattern = /^[0-9a-fA-F]{8}-[0-9a-fA-F]{4}-4[0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12}$/;
const text = "c9bf9e57-1685-4c89-bafb-ff5af830be8a";
const isMatch = pattern.test(text);
console.log("Is Match:", isMatch);
if (isMatch) {
const matches = text.match(pattern);
console.log("Matches:", matches);
}Regular Expression Token Breakdown
Ensures the 3rd section starts with 4 (version) and the 4th section starts with 8, 9, a, or b (variant 1). Each component of the regular expression serves a distinct syntactical purpose as mapped below:
| Token Pattern | Name / Component | Function & Rule |
|---|---|---|
| [0-9a-fA-F]{8} | Time-low | 8 hexadecimal characters. |
| [0-9a-fA-F]{4} | Time-mid | 4 hexadecimal characters. |
| 4[0-9a-fA-F]{3} | Version 4 | Must start with literal digit 4 followed by 3 hex chars. |
| [89abAB][0-9a-fA-F]{3} | Variant | Variant bits 8, 9, a, or b. |
| [0-9a-fA-F]{12} | Node | Final 12 hexadecimal characters. |
Frequently Asked Questions
How to match any UUID version (v1-v5)?
Related Regular Expressions
Browse All 40 PatternsCode & Markup
Git Commit SHA-1 & SHA-256
Matches Git commit SHA hashes: 7-character short commit IDs or 40-character full SHA-1 hashes.
/^\b([a-f0-9]{7}|[a-f0-9]{40})$/iTest regex
Authentication & Security
MD5 Hash Checksum
Matches 32-character hexadecimal MD5 hash checksum strings.
/^[a-fA-F0-9]{32}$/Test regex
Authentication & Security
SHA-256 Hash Checksum
Matches 64-character hexadecimal SHA-256 cryptographic digest strings.
/^[a-fA-F0-9]{64}$/Test regex