Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Regular expression for IFSC code(first four alphabet and then 7 digit.)

IFSC Code description:

  1. Exact length should be 11
  2. First 4 alphabets
  3. Fifth character is 0 (zero)
  4. Last six characters (usually numeric, but can be alphabetic)

E.g.

SBIN1234567

Here is what I tried but its not working.

("^[^\s]{4}\d{7}$")
like image 994
Abhay Kumar Avatar asked Sep 06 '16 05:09

Abhay Kumar


3 Answers

What about /^[A-Za-z]{4}\d{7}$/

Check here

Edit

As per definitions of IFSC code posted here in other answers, it is first 4 characters as digit and remaining 7 characters as alphanumeric , regex would be

^[A-Za-z]{4}[a-zA-Z0-9]{7}$

like image 83
Mudassir Hasan Avatar answered Oct 23 '22 13:10

Mudassir Hasan


According to Indian Financial System Code on wikipedia

IFSC Code Format:

1] Exact length should be 11

2] First 4 alphabets

3] Fifth character is 0 (zero)

4] Last six characters (usually numeric, but can be alphabetic)

Try this:-

^[A-Za-z]{4}0[A-Z0-9a-z]{6}$
like image 32
Satish Avatar answered Oct 23 '22 13:10

Satish


As per new rules, RBI changed it's guideline for IFSC Code,

New Format for IFSC Code : Eg. ABCD0123456

The IFSC is an 11-character code with the first four alphabetic characters representing the bank name, and the last six characters (usually numeric, but can be alphabetic) representing the branch. The fifth character is 0 (zero) and reserved for future use. Bank IFS Code is used by the NEFT & RTGS systems to route the messages to the destination banks/branches.

For Code Validation : "^[A-Z]{4}[0][A-Z0-9]{6}$"

For Java:

public static boolean isIfscCodeValid(String IFSCCode) 
{
    String regExp = "^[A-Z]{4}[0][A-Z0-9]{6}$";
    boolean isvalid = false;

    if (IFSCCode.length() > 0) {
        isvalid = IFSCCode.matches(regExp);
    }
    return isvalid;
}

where isIfscCodevalid() is common static method, which accepts string as parameter(String email) input from User and matches with regExp for IFSC Code Validation and returns the value as true or false.

like image 37
Rohit Mhatre Avatar answered Oct 23 '22 15:10

Rohit Mhatre