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

Australian Driver's Licence Number Regex for Java

/^[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 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
// Australian Driver's Licence Number
// ReDoS-safe | RegexVault — Identity & PII > Driver's License Numbers

import java.util.regex.Pattern;

public class AustralianDriversLicenceNumberValidator {
    private static final Pattern PATTERN =
        Pattern.compile("^[0-9A-Z]{6,9}$");

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

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

Test Cases

Matches (Valid)
Rejects (Invalid)
1234567812345
AB123456ABCDE12345
123456789123-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 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

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