Regex to Match Vehicle Identification Numbers (VIN)

Validate 17-character Vehicle Identification Numbers excluding letters I, O, and Q to prevent confusion with digits 1 and 0. Free online regex tester.

Regular Expression

/^[A-HJ-NPR-Z0-9]{17}$/i

Token Breakdown

TokenDescription
^Anchors at the start of the string (or line in multiline mode)
[A-HJ-NPR-Z0-9]Character class — matches any one of: A-HJ-NPR-Z0-9
{17}Matches exactly 17 times
$Anchors at the end of the string (or line in multiline mode)

Detailed Explanation

This regex validates Vehicle Identification Numbers (VIN) as standardized by ISO 3779. Here is the token-by-token breakdown:

^ — Anchors the match at the start of the string.

[A-HJ-NPR-Z0-9] — A character class matching the valid VIN characters. This includes uppercase letters A through H, J through N, P through R, and S through Z, plus digits 0 through 9. Notably excluded are the letters I, O, and Q. These letters are omitted from the VIN standard because I can be confused with the digit 1, O can be confused with the digit 0, and Q can be confused with O or 0.

{17} — Requires exactly 17 characters, the standard length for all VINs assigned since 1981.

$ — Anchors the match at the end of the string.

The i flag makes the match case-insensitive, accepting both uppercase and lowercase letters since VINs are case-insensitive in practice.

A VIN encodes detailed information about a vehicle: positions 1-3 form the World Manufacturer Identifier, positions 4-8 are the Vehicle Descriptor Section, position 9 is the check digit, position 10 indicates the model year, position 11 identifies the assembly plant, and positions 12-17 are the sequential production number.

Examples include: 1HGBH41JXMN109186 (Honda Civic), WVWZZZ3CZWE515029 (Volkswagen), and 5YJSA1DN5DFP14705 (Tesla Model S). This pattern validates the format but not the check digit in position 9. It is useful for vehicle registration systems, insurance applications, and automotive databases.

Example Test Strings

InputExpected
1HGBH41JXMN109186Match
WVWZZZ3CZWE515029Match
5YJSA1DN5DFP14705Match
1HGBH41JXMN1091No Match
ABCDEFGHIJKLMNOPQNo Match

Try It — Interactive Tester

//i
gimsuy
No matches found.
Pattern: 21 charsFlags: iMatches: 0

Ctrl+Shift+C to copy regex

Customize this pattern →