DevTools
Back to Regex Tester

UUID Regex Pattern

Match and validate UUID (Universally Unique Identifier) format v1-v5 using regex. Standard 8-4-4-4-12 hexadecimal format.

The Pattern

/[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

How It Works

TokenMeaning
[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

Test Cases

550e8400-e29b-41d4-a716-446655440000Match
6ba7b810-9dad-11d1-80b4-00c04fd430c8Match
123e4567-e89b-12d3-a456-426614174000Match
not-a-uuid-at-allNo match
550e8400-e29b-41d4-a716No match
550e8400e29b41d4a716446655440000No match

Code Examples

javascript
const 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"]
python
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']

Common Use Cases

Related Patterns

Want to test this pattern with your own data?

Try this pattern in Regex Tester →