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

Australian Driver's Licence Number Regex for Python

/^[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 Python. 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 Python project — whether you're validating in a Django view, a FastAPI endpoint, or a standalone data processing script.

Python Implementation

Python
# Australian Driver's Licence Number
# ReDoS-safe | RegexVault — Identity & PII > Driver's License Numbers

import re

australian_drivers_licence_number_pattern = re.compile(r'^[0-9A-Z]{6,9}$')

def validate_australian_drivers_licence_number(value: str) -> bool:
    return bool(australian_drivers_licence_number_pattern.fullmatch(value))

# Example
print(validate_australian_drivers_licence_number("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 Python developers because particularly important in Python web servers where CPU-bound regex operations can stall concurrent request handling. 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