REGEXVAULTv2.0
Web & Network/Misc
Verified Safe

UUID v1 Regex for Python

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

What this pattern does

This page provides a well-structured, multi-part regular expression for matching uuid v1, ported and verified for Python. A rigorously tested regex reduces debugging time and protects your application from edge-case failures. The snippet below is ready to drop into your Python project — whether you're validating in a Django view, a FastAPI endpoint, or a standalone data processing script.

Python Implementation

Python
# UUID v1
# ReDoS-safe | RegexVault — Web & Network > Misc

import re

uuid_v1_pattern = re.compile(r'^[0-9a-f]{8}-[0-9a-f]{4}-1[0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$')

def validate_uuid_v1(value: str) -> bool:
    return bool(uuid_v1_pattern.fullmatch(value))

# Example
print(validate_uuid_v1("a8098c1a-f86e-11da-bd1a-00112444be1e"))  # True

Test Cases

Matches (Valid)
Rejects (Invalid)
a8098c1a-f86e-11da-bd1a-00112444be1ea8098c1a-f86e-21da-bd1a-00112444be1e
6ba7b810-9dad-11d1-80b4-00c04fd430c8a8098c1a-f86e-11da-c01a-00112444be1e
00000000-0000-1000-8000-000000000000not-a-uuid
ffffffff-ffff-1fff-bfff-ffffffffffffa8098c1af86e11dabd1a00112444be1e

When to use this pattern

This pattern is drawn from the Web & Network > Misc category and carries a ReDoS-safe certification. That matters for Python developers because particularly important in Python web servers where CPU-bound regex operations can stall concurrent request handling. RegexVault audits patterns against known backtracking attack vectors, ensuring you have the necessary context before using this regex in a high-stakes production environment.

Common Pitfalls

The time component in UUID v1 encodes a 60-bit timestamp with 100-nanosecond precision — it can be decoded to determine when and potentially where an ID was generated.

Technical Notes

UUID v1 embeds the MAC address of the generating machine in the node field (last 12 hex chars) — a privacy concern. UUID v4 is preferred for security-sensitive identifiers.

Have a pattern that belongs in the vault?

Submit it for review — community-verified patterns get credited to your GitHub handle. Free submissions join the queue. Priority review available for $15.

Submit a Pattern