PatternRegex

Validate an IFSC code

Confirm an IFSC code matches the RBI layout: a 4-letter bank code, a reserved zero, then a 6-character branch code.

Last updated

Pattern
^[A-Z]{4}0[A-Z0-9]{6}$
Open in Regex Tester & Builder

Matches

  • SBIN0001234
  • HDFC0000001

Doesn’t match

  • SBIN1001234
  • sbin0001234

Why it’s written this way

The first four characters, [A-Z]{4}, identify the bank — 'SBIN' for State Bank of India, 'HDFC' for HDFC Bank — and the fifth character is a literal 0, reserved by the RBI for future use rather than being part of the bank or branch code.

The remaining [A-Z0-9]{6} identifies the specific branch and is alphanumeric because several banks use letters in that segment, not only digits.

Edge cases to know

  • →It confirms the code is shaped like a valid IFSC, not that the bank code or branch code actually exists — cross-check against the RBI's published list for that.
  • →It's case-sensitive: real IFSC codes are issued uppercase, so a lowercase value should be normalized before testing, not accepted as-is.
  • →The reserved 0 in position five is a current RBI convention, not a value this pattern can guarantee will hold if the scheme ever changes.

Part by part

^[A-Z]{4}
Four letters identifying the bank. These are stable — HDFC, ICIC, SBIN and so on — and rarely change except through a merger.
0
A literal zero in the fifth position, reserved by the Reserve Bank for future use. It has been zero since the format was defined, and a non-zero character there means a typo.
[A-Z0-9]{6}$
Six characters identifying the branch, alphanumeric because the space of six digits alone was not large enough.

Common mistakes

  • ^[A-Z]{4}[A-Z0-9]{7}$

    Dropping the fixed zero discards the cheapest check in the format. That fifth character is always zero, and accepting anything there lets an obvious typo through.

    ^[A-Z]{4}0[A-Z0-9]{6}$
  • ^[A-Za-z]{4}0[A-Za-z0-9]{6}$

    Accepting lowercase produces multiple stored forms of the same code, so comparisons fail. Uppercase before validating rather than loosening the pattern.

  • ^[A-Z]{4}0\d{6}$

    Restricting the branch part to digits rejects the many branches whose codes contain letters, so valid transfers are blocked at the form.

Questions

Why is the fifth character always zero?

It is reserved. The Reserve Bank set it aside when defining the format and has never used it, which conveniently gives every IFSC a fixed checkpoint that catches mistyped codes immediately.

Does a match mean the branch exists?

No. The RBI publishes the authoritative list and it changes with every merger and branch closure — bank mergers in particular invalidate large blocks of codes at once. Validate against current data before initiating a transfer.

Can I derive the bank from the first four letters?

Usually, yes, and it is a good way to show the bank name back to the user for confirmation. Be careful around merged banks, where old prefixes may still appear on cheque books long after the codes changed.

Is IFSC the same as a SWIFT code?

No. IFSC identifies a specific branch for domestic transfers within India; SWIFT identifies an institution for international ones. A transfer from abroad usually needs both, and they are not interchangeable.

Where does a customer find their IFSC?

It is printed on the cheque book and shown in net banking, and every bank publishes a branch search. Asking users to read it off a cheque is the most reliable route, since the code identifies the branch where the account was opened rather than where they now live.

Related in Patterns