Regex for Driving License Number Validation in India

Indian driving license numbers loosely follow a national format, but because each state's RTO historically issued numbers with slightly different conventions, a single strict regex will reject some genuinely valid numbers. This guide gives you the common pattern plus a more permissive fallback for real-world data.

The Standard Format

A typical driving license number looks like MH1220230012345 and breaks down as:

  • State code — 2 letters, e.g. MH (Maharashtra), DL (Delhi), KA (Karnataka)
  • RTO code — 2 digits identifying the district transport office, e.g. 12
  • Year of issue — 4 digits, e.g. 2023
  • Unique serial number — typically 7 digits, e.g. 0012345

Numbers are often printed without separators, but forms and scanned records sometimes store a space or hyphen after the state/RTO segment (MH12 20230012345 or MH12-20230012345).

Regex for the Standard Format

const dlRegex = /^[A-Z]{2}[0-9]{2}[ -]?(19|20)[0-9]{2}[0-9]{7}$/;

function isValidDrivingLicense(input) {
  const normalized = input.trim().toUpperCase();
  return dlRegex.test(normalized);
}

isValidDrivingLicense('MH1220230012345');    // true
isValidDrivingLicense('MH12 20230012345');   // true
isValidDrivingLicense('MH12-20230012345');   // true
isValidDrivingLicense('MH1220230012');       // false — serial too short

Why the Format Varies by State

The Ministry of Road Transport and Highways standardized the DL number structure under the Sarathi system, but older licenses issued before full digitization — and some states' own numbering conventions — don't always match the modern 15-16 character layout exactly. You may encounter numbers with:

  • A serial number with 6 digits instead of 7 in older records
  • An extra space or slash between the RTO code and the rest of the number
  • A 2-digit year instead of 4-digit in pre-2000s licenses

Because of this, treat strict regex validation as a first-pass sanity check rather than the final word — pair it with a lenient fallback and a manual review path for anything that fails:

// More permissive: state code + RTO + 11-13 trailing digits, tolerant of separators
const dlLenient = /^[A-Z]{2}[0-9]{2}[ -]?[0-9]{11,13}$/;

dlLenient.test('MH1220230012345'); // true
dlLenient.test('KA0519850012345'); // true — older format, still passes

Practical Validation Strategy

  1. Normalize input — strip spaces/hyphens, convert to uppercase
  2. Run the strict regex first for the common modern format
  3. If it fails, fall back to the lenient pattern rather than outright rejecting the input
  4. For anything used in a legal/compliance context (insurance, fleet onboarding), verify against the government's Sarathi/VAHAN Parivahan API rather than relying on format checks alone

Frequently Asked Questions

What is the format of an Indian driving license number?

The common format is a 2-letter state code, a 2-digit RTO code, a 4-digit year of issue, and a 7-digit unique serial number, e.g. MH1220230012345. Some states use slight variations in digit grouping.

What is the regex for a standard Indian driving license number?

A practical pattern is ^[A-Z]{2}[0-9]{2}[ -]?(19|20)[0-9]{2}[0-9]{7}$, which matches the common state code + RTO code + year + serial number structure, allowing an optional space or hyphen after the RTO code.

Why does the driving license format vary by state in India?

Because license numbers are issued by each state's Regional Transport Office under a shared national guideline, but historically some states used slightly different digit groupings or serial lengths before standardization. A strict regex tuned for one state may reject valid numbers from another.

Try the Free AI Regex Generator

Describe any validation rule in plain English and get a working regex instantly — no signup required.

Related articles