Start free · Free tools · Fair usage limits
Browse Tools

Categories

Custom AI Solutions – AI2Flows
LIVE NEWS
Loading latest AI & SEO news…
Home›Tools›Regex Tester›Regex for IBAN
Regex pattern · validation

Regex for IBAN

Regex for IBAN: a tested pattern with examples, a plain-English breakdown, and code for JavaScript, Python, PHP, Java and Go.

Quick answer

Use /^[A-Z]{2}\d{2}[A-Z0-9]{11,30}$/ as an IBAN regex. It matches "GB82WEST12345698765432" and "DE89370400440532013000", and rejects "gb82west12345698765432" and "GB82 WEST 1234 5698 7654 32". Remove spaces and uppercase first.

Last updated · Maintained by FreeAIToolz · How we test

/^[A-Z]{2}\d{2}[A-Z0-9]{11,30}$/
  • GB82WEST12345698765432matches
  • DE89370400440532013000matches
  • PK36SCBL0000001123456702matches
  • gb82west12345698765432no match
  • GB82 WEST 1234 5698 7654 32no match
  • GB8no match
  • 1234567890123456no match
Open in the full Regex Tester (replace, flags, groups) →

How this regex works

PartMeaning
^[A-Z]{2}two-letter country code
\d{2}two check digits
[A-Z0-9]{11,30}$country-specific account number (total length 15–34)

Examples

InputResult
GB82WEST12345698765432✓ Matches
DE89370400440532013000✓ Matches
PK36SCBL0000001123456702✓ Matches
gb82west12345698765432✗ No match
GB82 WEST 1234 5698 7654 32✗ No match
GB8✗ No match
1234567890123456✗ No match

Every example above is checked automatically in JavaScript and Python each time the site is built.

Limitations and edge cases

Remove spaces and uppercase first. Each country has a fixed length, and the check digits need a mod-97 calculation; validate with a library before sending payments.

When to use this pattern

Payment and payout forms for European, Middle East and Pakistani bank accounts.

Use it in your language

JavaScript

const re = /^[A-Z]{2}\d{2}[A-Z0-9]{11,30}$/;
re.test(input); // true or false

Python

import re
pattern = re.compile(r'^[A-Z]{2}\d{2}[A-Z0-9]{11,30}$')
bool(pattern.search(value))

PHP

$ok = preg_match('~^[A-Z]{2}\\d{2}[A-Z0-9]{11,30}$~', $value) === 1;

Java

Pattern pattern = Pattern.compile("^[A-Z]{2}\\d{2}[A-Z0-9]{11,30}$");
boolean ok = pattern.matcher(value).find();

Go

re := regexp.MustCompile(`^[A-Z]{2}\d{2}[A-Z0-9]{11,30}$`)
ok := re.MatchString(value)

More regex patterns

Frequently asked questions

What is the regex for IBAN?
/^[A-Z]{2}\d{2}[A-Z0-9]{11,30}$/. Remove spaces and uppercase first. Each country has a fixed length, and the check digits need a mod-97 calculation; validate with a library before sending payments.
Which languages does this pattern work in?
It is tested in JavaScript and Python and uses syntax that also works in PHP (PCRE) and Java. It also works in Go’s RE2 engine.
Why does the pattern start with ^ and end with $?
They anchor the match to the whole string, so "abcGB82WEST12345698765432xyz" cannot pass just because it contains a valid part. To search for matches inside longer text, remove ^ and $ (use \b where word boundaries help) and add the g flag.