UK DVLA Driver's License Number Regex for Go
/^[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 Go. 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 Go project — whether you're validating in a Gin handler, a gRPC service, or a command-line tool.
Go Implementation
// UK DVLA Driver's License Number
// ReDoS-safe | RegexVault — Identity & PII > Driver's License Numbers
package validation
import "regexp"
var ukDvlaDriversLicenseNumberRe = regexp.MustCompile(`^[A-Z9]{5}[0-9]{6}[A-Z9]{2}[A-Z0-9]{2}[A-Z]{1,2}[0-9]$`)
func ValidateUkDvlaDriversLicenseNumber(s string) bool {
return ukDvlaDriversLicenseNumberRe.MatchString(s)
}
// Example
// fmt.Println(ValidateUkDvlaDriversLicenseNumber("SMITH691203A99AB5")) // trueTest 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 Go developers because Go's RE2 engine is inherently safe from catastrophic backtracking, but this pattern has been additionally verified for correctness. 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