DD
DevDash

Regex for US License Plate

Regex Pattern

^[A-Z0-9]{1,8}$

US license plate — 1-8 uppercase alphanumeric characters

Quick Answer

The regex pattern for us license plate is `^[A-Z0-9]{1,8}$`. US license plate — 1-8 uppercase alphanumeric characters. This works in JavaScript, Python, Ruby, PHP, Java, and most regex engines that support PCRE syntax.

Test Examples

InputResult
ABC1234✓ Matches
7ABC123✓ Matches
VANITY✓ Matches
abc1234✗ No match
TOO-LONG-PLATE✗ No match
HAS SPACE✗ No match

Code Examples

javascript

const regex = /^[A-Z0-9]{1,8}$/;
const isValid = regex.test(value);

python

import re
pattern = r'^[A-Z0-9]{1,8}$'
if re.match(pattern, value):
    print("valid")

ruby

pattern = /^[A-Z0-9]{1,8}$/
if value =~ pattern
  puts "valid"
end

php

if (preg_match('/^[A-Z0-9]{1,8}$/', $value)) {
    echo "valid";
}

java

String pattern = "^[A-Z0-9]{1,8}$";
boolean isValid = value.matches(pattern);

Frequently Asked Questions

Related Regex Patterns

Want API access + no ads? Pro coming soon.