DD
DevDash

Regex for US Routing Number

Regex Pattern

^\d{9}$

US bank routing number (ABA) — exactly 9 digits

Quick Answer

The regex pattern for us routing number is `^\d{9}$`. US bank routing number (ABA) — exactly 9 digits. This works in JavaScript, Python, Ruby, PHP, Java, and most regex engines that support PCRE syntax.

Test Examples

InputResult
021000021✓ Matches
121042882✓ Matches
011401533✓ Matches
12345678✗ No match
1234567890✗ No match
ABCDEFGHI✗ No match

Code Examples

javascript

const regex = /^\d{9}$/;
const isValid = regex.test(value);

python

import re
pattern = r'^\d{9}$'
if re.match(pattern, value):
    print("valid")

ruby

pattern = /^\d{9}$/
if value =~ pattern
  puts "valid"
end

php

if (preg_match('/^\d{9}$/', $value)) {
    echo "valid";
}

java

String pattern = "^\\d{9}$";
boolean isValid = value.matches(pattern);

Frequently Asked Questions

Related Regex Patterns

Want API access + no ads? Pro coming soon.