Regex for UUID
Part of the Regex Toolkit^[0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[1-8][0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12}$case-insensitive built into the pattern itself — no i flag required
Explanation
A UUID's shape is fixed — 32 hex digits split into groups of 8-4-4-4-12 by hyphens, 550e8400-e29b-41d4-a716-446655440000 — but two of those digits aren't random at all. This pattern checks the shape and both fixed digits, not just "32 hex characters with hyphens in the right places."
The first character of the third group is the version — which generation algorithm produced the UUID — and RFC 9562 (2024, superseding RFC 4122) defines versions 1 through 8, so anything else there means the string isn't a real UUID. The first character of the fourth group is the variant, and for every UUID version in common use it's always 8, 9, a, or b. This site's own UUID Generator produces v1, v4, and v7 UUIDs — all three match this pattern, since all three set both digits correctly.
One real edge case: the Nil UUID (00000000-...-000000000000, all zeros) is a defined, valid sentinel value used to mean "no UUID" — but its version digit is 0, so this pattern correctly treats it as not-a-real-UUID rather than as version zero. If your data might legitimately contain the Nil UUID as a placeholder, check for it as a special case before running this pattern.
Valid examples
550e8400-e29b-41d4-a716-446655440000A v4 (random) UUID — the version digit is 4, the classic textbook example.
6BA7B810-9DAD-11D1-80B4-00C04FD430C8RFC 4122's predefined DNS namespace UUID (version-1-shaped), shown uppercase to confirm case doesn't matter.
018f1b2c-7e3a-7c4d-8b2e-1a2b3c4d5e6fA v7 (timestamp-ordered) UUID, the format this site's UUID Generator can produce for sortable database keys.
Invalid examples
00000000-0000-0000-0000-000000000000The Nil UUID — a real, defined sentinel value, but its version digit is 0, which isn't 1-8.
550e8400-e29b-41d4-a716-44665544000One hex digit short in the last group — the grouping and length matter, not just "looks hex-and-hyphen-shaped."
gggggggg-e29b-41d4-a716-446655440000Right shape (8-4-4-4-12), wrong character set in the first group — g isn't a hex digit.