Australian Driver's Licence Number Regex for JavaScript
/^[0-9A-Z]{6,9}$/What this pattern does
This page provides a lightweight, single-purpose regular expression for matching australian driver's licence number, ported and verified for JavaScript. 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 JavaScript project — whether you're validating in an Express middleware, a Next.js API route, or a client-side form.
Javascript Implementation
// Australian Driver's Licence Number
// ReDoS-safe | RegexVault — Identity & PII > Driver's License Numbers
const australianDriversLicenceNumberRegex = /^[0-9A-Z]{6,9}$/;
function validateAustralianDriversLicenceNumber(input: string): boolean {
return australianDriversLicenceNumberRegex.test(input);
}
// Example
console.log(validateAustralianDriversLicenceNumber("12345678")); // trueTest Cases
Matches (Valid) | Rejects (Invalid) |
|---|---|
12345678 | 12345 |
AB123456 | ABCDE12345 |
123456789 | 123-456-789 |
A12345 | — |
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 JavaScript developers because especially critical in long-running Node.js event loops where a ReDoS vulnerability can block the entire process. 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
Australian states have separate, non-compatible licence formats. A Victorian licence number (1 letter + 8 digits) may look identical to a NSW number in format but they are structurally different.
Technical Notes
State formats: NSW (6 digits), VIC (1 letter + 8 digits), QLD (8-9 digits), WA (7 digits), SA (6 digits + 1 letter), TAS (6-8 digits), ACT (10 digits), NT (10 digits). Use state-aware validation when the state is known.
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