Regex tester / pattern library

Regex: uuid

/^[0-9a-f]{8}-[0-9a-f]{4}-[1-8][0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$/i Test it live

How it works

8-4-4-4-12 hex groups. The third group must start with the version digit (1–8) and the fourth with the RFC variant bits (8, 9, a, or b). The i flag accepts uppercase UUIDs.

Honest caveats

Rejects the all-zero nil UUID and Microsoft-variant GUIDs — drop the position constraints to [0-9a-f] if you need those.

Matches

  • 0198f78e-fd00-74b6-94e4-ed84f1190de8
  • C232AB00-9414-11EC-B3C8-9F6BDECED846

Doesn't match

  • 0198f78e-fd00-04b6-94e4-ed84f1190de8
  • not-a-uuid
  • 0198f78efd0074b694e4ed84f1190de8

More patterns