New blogMaking an AI Agent You Can Trust With Money

★ India · regex

Regex for IFSC Code

The Indian Financial System Code identifies a bank branch for NEFT, RTGS and IMPS. The first four letters are the bank, the fifth character is always 0 (reserved), and the last six identify the branch.

  • Runs in your browser
  • No signup

Try the ifsc code pattern

Read it in plain English (best-effort)

  • ^start of a line
  • [A-Z]one character from: A–Z
  • {4}exactly 4 of the previous
  • 0the character '0'
  • [A-Z0-9]one character from: A–Z, 0–9
  • {6}exactly 6 of the previous
  • $end of a line

One sample per line works well with the m flag on anchored patterns.

Waiting for a pattern
01

The pattern, piece by piece

/^[A-Z]{4}0[A-Z0-9]{6}$/
Pattern explanation
PartWhat it does
^[A-Z]{4}bank code, e.g. SBIN for State Bank of India
0the fifth character is always zero
[A-Z0-9]{6}$branch code
02

What it accepts and rejects

Every sample below is checked automatically in JavaScript and Python. The tester above is preloaded with all of them, one per line.

Should match
Should match
SBIN0001234✓
HDFC0000123✓
ICIC0ABC123✓
RBIS0COD001✓
UTIB0000001✓
KKBK0000958✓
Should not match
Should not match
SBIN1001234✗
SBIN000123✗
sbin0001234✗
SBI00001234✗
SBIN00012345✗
SBIN-0001234✗
03

Copy it into your code

RE2-safeNo lookarounds or backreferences, so the same pattern works in Go's RE2 engine and in Rust's regex crate.

const ifscRe = /^[A-Z]{4}0[A-Z0-9]{6}$/;

export function isValidIfsc(value) {
  return ifscRe.test(value.trim());
}
04

When not to use regex for this

To check an IFSC exists and get the branch address, use RBI's published IFSC list or a lookup API, and refresh it periodically as branches merge.

05

Questions engineers actually ask

Why is the fifth character always 0?
It's reserved for future use, so every current IFSC has a zero in that position.
Is IFSC case-sensitive?
Codes are uppercase. Uppercase user input before validating.
What is catastrophic backtracking?
Some patterns, usually nested quantifiers like (a+)+, make a backtracking engine try an exponential number of paths on input that almost matches. The tester stops any run after 300ms, so a bad pattern can't freeze your tab. In production, that same pattern can take down a server (a ReDoS attack).
06

Sources

Formats were checked on 8 November 2026. Rules change; the official issuer wins if it disagrees.

07

More india patterns

08

More from the workbench

Fine print

Tools: on the house.
Engineer: by the hour.

The regex was free. Code that doesn't need one is the upgrade: typed schemas, validated once at the edge, trusted everywhere after.

I'm Himanshu, an AI and full-stack engineer. I build MVPs, AI agents and the growth plumbing around them for early-stage startups.