REGEXVAULTv2.0
Web & Network/Misc
Verified Safe

UUID v1 Regex for PHP

/^[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 PHP. A rigorously tested regex reduces debugging time and protects your application from edge-case failures. The snippet below is ready to drop into your PHP project — whether you're validating in a Laravel validator, a WordPress plugin, or a standalone PHP script.

Php Implementation

Php
<?php
// UUID v1
// ReDoS-safe | RegexVault — Web & Network > Misc

define('UUID_V1_PATTERN', '/^[0-9a-f]{8}-[0-9a-f]{4}-1[0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$/');

function validate_uuid_v1(string $input): bool {
    return (bool) preg_match(UUID_V1_PATTERN, $input);
}

// Example
var_dump(validate_uuid_v1("a8098c1a-f86e-11da-bd1a-00112444be1e")); // bool(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 PHP developers because especially relevant in PHP where PCRE backtracking limits can trigger silent failures on malicious input. 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