Regex for Matching a UUID

Matches the standard 8-4-4-4-12 hexadecimal UUID format.

Published October 11, 2026

Matches the standard 8-4-4-4-12 hexadecimal UUID format.

Key points

  • Add the i (case-insensitive) flag since UUIDs are sometimes written in uppercase
  • Version-specific UUID patterns further constrain certain digit positions to identify the UUID version

Example

^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$
More General articles