Match and validate UUID (Universally Unique Identifier) format v1-v5 using regex. Standard 8-4-4-4-12 hexadecimal format.
/[0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{12}/g| Token | Meaning |
|---|---|
[0-9a-fA-F]{8} | First group: exactly 8 hex characters |
- | Literal dash separator |
[0-9a-fA-F]{4} | Second group: exactly 4 hex characters |
- | Literal dash separator |
[0-9a-fA-F]{4} | Third group: exactly 4 hex characters (version) |
- | Literal dash separator |
[0-9a-fA-F]{4} | Fourth group: exactly 4 hex characters (variant) |
- | Literal dash separator |
[0-9a-fA-F]{12} | Fifth group: exactly 12 hex characters |
550e8400-e29b-41d4-a716-446655440000Match6ba7b810-9dad-11d1-80b4-00c04fd430c8Match123e4567-e89b-12d3-a456-426614174000Matchnot-a-uuid-at-allNo match550e8400-e29b-41d4-a716No match550e8400e29b41d4a716446655440000No matchconst uuidRegex = /[0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{12}/g;
const text = "User ID: 550e8400-e29b-41d4-a716-446655440000, Order: 6ba7b810-9dad-11d1-80b4-00c04fd430c8";
const matches = text.match(uuidRegex);
console.log(matches); // ["550e8400-e29b-41d4-a716-446655440000", "6ba7b810-9dad-11d1-80b4-00c04fd430c8"]import re
uuid_regex = r'[0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{12}'
text = "User ID: 550e8400-e29b-41d4-a716-446655440000"
matches = re.findall(uuid_regex, text)
print(matches) # ['550e8400-e29b-41d4-a716-446655440000']Want to test this pattern with your own data?
Try this pattern in Regex Tester →