Regex for VIN (Vehicle ID)
Regex Pattern
^[A-HJ-NPR-Z0-9]{17}$Vehicle Identification Number — 17 alphanumeric chars (no I, O, Q)
Quick Answer
The regex pattern for vin (vehicle id) is `^[A-HJ-NPR-Z0-9]{17}$`. Vehicle Identification Number — 17 alphanumeric chars (no I, O, Q). This works in JavaScript, Python, Ruby, PHP, Java, and most regex engines that support PCRE syntax.
Test Examples
| Input | Result |
|---|---|
| 1HGCM82633A004352 | ✓ Matches |
| JH4KA8260MC000000 | ✓ Matches |
| 5YJSA1E14HF000001 | ✓ Matches |
| 1HGCM82633A00435 | ✗ No match |
| 1HGCM82633A0043521 | ✗ No match |
| IHGCM82633A004352 | ✗ No match |
Code Examples
javascript
const regex = /^[A-HJ-NPR-Z0-9]{17}$/;
const isValid = regex.test(value);python
import re
pattern = r'^[A-HJ-NPR-Z0-9]{17}$'
if re.match(pattern, value):
print("valid")ruby
pattern = /^[A-HJ-NPR-Z0-9]{17}$/
if value =~ pattern
puts "valid"
endphp
if (preg_match('/^[A-HJ-NPR-Z0-9]{17}$/', $value)) {
echo "valid";
}java
String pattern = "^[A-HJ-NPR-Z0-9]{17}$";
boolean isValid = value.matches(pattern);Frequently Asked Questions
Related Regex Patterns
UUID v4
UUID version 4 (randomly generated)
UUID (Any Version)
Any RFC 4122 UUID (versions 1-5)
JWT Token
JSON Web Token (header.payload.signature)
Hex String
Any-length hexadecimal string
Base64 String
Standard base64 encoded string
Alphanumeric Username
Username with letters, digits, underscores (3-16 chars)