Regex to Match US Passport Numbers
Validate US passport numbers with this regex pattern. Matches one uppercase letter followed by eight digits. Free online regex tool.
Regular Expression
/^[A-Z]\d{8}$/
Token Breakdown
| Token | Description |
|---|---|
| ^ | Anchors at the start of the string (or line in multiline mode) |
| [A-Z] | Character class — matches any one of: A-Z |
| \d | Matches any digit (0-9) |
| {8} | Matches exactly 8 times |
| $ | Anchors at the end of the string (or line in multiline mode) |
Detailed Explanation
This regex validates US passport numbers, which consist of one uppercase letter followed by eight digits. Here is the token-by-token breakdown:
^ — Anchors the match at the start of the string. This ensures no characters precede the passport number.
[A-Z] — A character class matching a single uppercase letter from A to Z. US passport numbers begin with one letter that indicates the passport book type or series. This class is case-sensitive (no i flag), so only uppercase letters are accepted, matching how passport numbers are officially printed.
\d{8} — Matches exactly eight digits. The \d shorthand is equivalent to [0-9], and the {8} quantifier requires precisely eight occurrences. Together with the leading letter, this creates the standard nine-character US passport number format.
$ — Anchors the match at the end of the string, ensuring no trailing characters.
US passport numbers follow a simple alphanumeric format: one letter followed by eight digits, for a total of nine characters. Examples include A12345678 and C00112233. This pattern performs format validation only and does not check whether the passport number has actually been issued or is currently valid. Different countries have different passport number formats. For example, UK passports use nine digits without a letter prefix, and Canadian passports have two letters followed by six digits. If you need to validate passports from multiple countries, you would need separate patterns or a more complex alternation.
Example Test Strings
| Input | Expected |
|---|---|
| A12345678 | Match |
| C00112233 | Match |
| a12345678 | No Match |
| AB1234567 | No Match |
| 123456789 | No Match |
Try It — Interactive Tester
12 charsFlags: noneMatches: 0Ctrl+Shift+C to copy regex
Related Regex Patterns
Regex to Match Social Security Numbers
/^(?!000|666|9\d{2})\d{3}-(?!00)\d{2}-(?!0000)\d{4}$/
Regex to Match Credit Card Numbers
/^(?:4\d{3}|5[1-5]\d{2}|3[47]\d{2}|6(?:011|5\d{2}))[\s-]?\d{4}[\s-]?\d{4}[\s-]?\d{1,4}$/
Regex to Validate UUIDs
/^[0-9a-f]{8}-[0-9a-f]{4}-[1-7][0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$/i
Regex to Match Alphanumeric Strings
/^[a-zA-Z0-9]+$/