UUID (v1–v5)
Match RFC 4122 UUIDs (versions 1–5) in the standard 8-4-4-4-12 hex format.
Try it in RegexPro →Available in
Pattern
[0-9a-f]{8}-[0-9a-f]{4}-[1-5][0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12} (flags: gi)Raw source: [0-9a-f]{8}-[0-9a-f]{4}-[1-5][0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}
How it works
Examples
Input
550e8400-e29b-41d4-a716-446655440000Matches
550e8400-e29b-41d4-a716-446655440000
Input
6ba7b810-9dad-11d1-80b4-00c04fd430c8Matches
6ba7b810-9dad-11d1-80b4-00c04fd430c8
Common use cases
- •Database primary key validation
- •API request ID extraction from logs
- •Distributed system tracing
- •Config file ID validation
Related patterns
AWS S3 Bucket Name
IdentifiersValidate AWS S3 bucket names per the standard naming rules: 3–63 chars, lowercase, alphanumeric + dots + hyphens.
Kubernetes Pod Name (RFC 1123)
IdentifiersValidate Kubernetes pod names per the RFC 1123 DNS label rules — lowercase, ≤63 chars, no leading/trailing hyphen.
AWS ARN (Amazon Resource Name)
IdentifiersMatch AWS ARNs (Amazon Resource Names) across commercial, China, and GovCloud partitions.
Docker Image Tag
IdentifiersMatch Docker image references with an explicit tag — e.g. nginx:1.21, mycorp/service:v2.3.1.
Related concepts
Custom Character Sets: [abc], [a-z], [^abc]
ConceptSquare brackets build a custom character class. [abc] matches any of a, b, or c. [a-z] is a range. A leading ^ negates the set.
Quantifiers: *, +, ?, and {n,m}
ConceptQuantifiers repeat the preceding element. * is 0 or more, + is 1 or more, ? is 0 or 1. {n}, {n,}, and {n,m} give exact counts and ranges.
Regex Flags in JavaScript: g, i, m, s, u, y
ConceptFlags modify regex behavior globally. g enables global matching, i makes it case-insensitive, m changes anchor behavior, s dots match newlines, u enables Unicode, y is sticky.
How to Match a Specific Number of Characters
How-toUse {n} for exactly n, {n,} for n or more, {n,m} for between n and m. Apply to any single token — character, class, or group.