Australian Driver's Licence Number Regex for Go
/^[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 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
// Australian Driver's Licence Number
// ReDoS-safe | RegexVault — Identity & PII > Driver's License Numbers
package validation
import "regexp"
var australianDriversLicenceNumberRe = regexp.MustCompile(`^[0-9A-Z]{6,9}$`)
func ValidateAustralianDriversLicenceNumber(s string) bool {
return australianDriversLicenceNumberRe.MatchString(s)
}
// Example
// fmt.Println(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 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
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