REGEXVAULTv2.0
Identity & PII/Driver's License Numbers
Verified Safe

UK DVLA Driver's License Number Regex for Java

/^[A-Z9]{5}[0-9]{6}[A-Z9]{2}[A-Z0-9]{2}[A-Z]{1,2}[0-9]$/i

What 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 Java. 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 Java project — whether you're validating in a Spring Boot controller, a Jakarta EE service, or a standalone utility class.

Java Implementation

Java
// UK DVLA Driver's License Number
// ReDoS-safe | RegexVault — Identity & PII > Driver's License Numbers

import java.util.regex.Pattern;

public class UkDvlaDriversLicenseNumberValidator {
    private static final Pattern PATTERN =
        Pattern.compile("^[A-Z9]{5}[0-9]{6}[A-Z9]{2}[A-Z0-9]{2}[A-Z]{1,2}[0-9]$");

    public static boolean validate(String input) {
        return PATTERN.matcher(input).matches();
    }

    // Example
    public static void main(String[] args) {
        System.out.println(validate("SMITH691203A99AB5")); // true
    }
}

Test Cases

Matches (Valid)
Rejects (Invalid)
SMITH691203A99AB5MORGA65705SM9IJ
JONES701215D99CD3morga657054sm9ij
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 Java developers because critical in Java applications since the JVM regex engine uses backtracking and is susceptible to ReDoS without careful pattern design. 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