UUID (v4) Regex Pattern
Validates UUID version 4 format with the version nibble (4) and variant bits (8, 9, a, b) in correct positions.
Live Regex Tester
Pattern Breakdown
Code Examples
JavaScript
const regex = /^[0-9a-f]{8}-[0-9a-f]{4}-4[0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$/i;
const test = "550e8400-e29b-41d4-a716-446655440000";
console.log(regex.test(test)); // true
// Extract matches
const matches = test.match(regex);
console.log(matches);Python
import re
pattern = r'^[0-9a-f]{8}-[0-9a-f]{4}-4[0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$'
test = "550e8400-e29b-41d4-a716-446655440000"
match = re.search(pattern, test, re.IGNORECASE)
print(match) # Found!Go
package main
import (
"fmt"
"regexp"
)
func main() {
re := regexp.MustCompile(`^[0-9a-f]{8}-[0-9a-f]{4}-4[0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$`)
fmt.Println(re.MatchString("550e8400-e29b-41d4-a716-446655440000")) // true
}Common Use Cases
Match Examples
| Input | Result |
|---|---|
| 550e8400-e29b-41d4-a716-446655440000 | Match |
| 550e8400-e29b-51d4-a716-446655440000 | No Match |
About the UUID (v4) Regex
Validates UUID version 4 format with the version nibble (4) and variant bits (8, 9, a, b) in correct positions.
Regular expressions (regex) are powerful pattern matching tools used across virtually all programming languages. The uuid (v4) pattern is classified as intermediate difficulty in the security & auth category. It works in all major programming languages.
When using this regex, always consider edge cases and test thoroughly with real-world data. Use the interactive tester above to validate the pattern against your specific inputs before deploying to production.
More Security & Auth Patterns
Need More Regex Patterns?
Browse our complete library of 100+ regex patterns with interactive testers.
Frequently Asked Questions
What is the UUID (v4) regex pattern?
Validates UUID version 4 format with the version nibble (4) and variant bits (8, 9, a, b) in correct positions.
How do I use the UUID (v4) regex?
Use the pattern /^[0-9a-f]{8}-[0-9a-f]{4}-4[0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$/i in your code. In JavaScript: new RegExp('^[0-9a-f]{8}-[0-9a-f]{4}-4[0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$', 'i'). Test it above with your own input.
What does this UUID (v4) regex match?
This pattern matches: "550e8400-e29b-41d4-a716-446655440000". It does NOT match: "550e8400-e29b-51d4-a716-446655440000". ID validation, database records, API responses.
Is the UUID (v4) regex beginner-friendly?
This pattern is rated Intermediate. It uses some advanced features like character classes and quantifiers.
What languages support the UUID (v4) regex?
This pattern works in all major programming languages including JavaScript, Python, Java, C#, Go, Ruby, PHP, and more. Syntax may vary slightly between regex engines.
Can I modify the UUID (v4) regex for my use case?
Yes! Use the interactive tester above to modify the pattern and test with your own data. Common modifications include making it case-insensitive (add 'i' flag), matching globally (add 'g' flag), or adjusting character classes.
Related Tools
JWT Token Regex
Intermediate Security & Auth pattern
API Key Pattern Regex
Advanced Security & Auth pattern
AWS Access Key Regex
Intermediate Security & Auth pattern
Base64 Encoded String Regex
Beginner Security & Auth pattern
MD5 Hash Regex
Beginner Security & Auth pattern
SHA-256 Hash Regex
Beginner Security & Auth pattern