UK DVLA Driver's License Number Regex for PHP
/^[A-Z9]{5}[0-9]{6}[A-Z9]{2}[A-Z0-9]{2}[A-Z]{1,2}[0-9]$/iWhat this pattern does
This page provides a well-structured, multi-part regular expression for matching uk dvla driver's license number, ported and verified for PHP. Identity and credential patterns need both correctness and safety, since they're frequent targets for adversarial input. 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
// UK DVLA Driver's License Number
// ReDoS-safe | RegexVault — Identity & PII > Driver's License Numbers
define('UK_DVLA_DRIVERS_LICENSE_NUMBER_PATTERN', '/^[A-Z9]{5}[0-9]{6}[A-Z9]{2}[A-Z0-9]{2}[A-Z]{1,2}[0-9]$/');
function validate_uk_dvla_drivers_license_number(string $input): bool {
return (bool) preg_match(UK_DVLA_DRIVERS_LICENSE_NUMBER_PATTERN, $input);
}
// Example
var_dump(validate_uk_dvla_drivers_license_number("SMITH691203A99AB5")); // bool(true)Test Cases
Matches (Valid) | Rejects (Invalid) |
|---|---|
SMITH691203A99AB5 | MORGA65705SM9IJ |
JONES701215D99CD3 | morga657054sm9ij |
| — | MORGA657054SM9I |
| — | M0RGA657054SM9IJ |
When to use this pattern
This pattern is drawn from the Identity & PII > Driver's License Numbers 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
UK driving licence numbers encode personal data by design. A change of name (e.g., after marriage) requires a new licence with a new number. The encoded gender is binary — the DVLA is updating this for non-binary licence holders.
Technical Notes
UK DL structure: surname (first 5 chars, padded with 9), birth decade digit + DOB (MDDYM where M is month, padded for females with 5 added to month), initials + suffix digits. Encodes surname, DOB, and gender — extremely information-dense PII.
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