UUID

Validation

Matches valid UUID/GUID format.

Regex Pattern

Flags: i
^[0-9a-f]{8}-[0-9a-f]{4}-[1-5][0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$

✓ Matches

  • 550e8400-e29b-41d4-a716-446655440000
  • 6ba7b810-9dad-11d1-80b4-00c04fd430c8

✗ Does Not Match

  • 550e8400-e29b-41d4-a716
  • not-a-uuid
  • 550e8400e29b41d4a716446655440000

Code Examples

1const regex = /^[0-9a-f]{8}-[0-9a-f]{4}-[1-5][0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$/i;
2const str = '550e8400-e29b-41d4-a716-446655440000';
3
4// Test if string matches
5const isMatch = regex.test(str);
6console.log('Match found:', isMatch);
7
8// Find all matches (add 'g' flag for multiple matches)
9const matches = str.match(regex);
10console.log('Matches:', matches);
11
12// Find matches with details
13let match;
14const regexWithGlobal = /^[0-9a-f]{8}-[0-9a-f]{4}-[1-5][0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$/ig;
15while ((match = regexWithGlobal.exec(str)) !== null) {
16 console.log('Match:', match[0], 'Index:', match.index);
17}

About UUID Regular Expression

This regex pattern is designed to matches valid uuid/guid format.. It can be used in JavaScript, Python, PHP, Java, and other programming languages that support regular expressions.

How to Use This Pattern

  1. Copy the regex pattern above
  2. Use the "Try in Tester" button to test it with your own data
  3. Use the code generator to get implementation code in your preferred language

Pattern Breakdown

Understanding each part of this regex will help you modify it for your specific needs. Click the "Explanation" tab in the tester to see a detailed breakdown of each component.