Arjun Kesava
Arjun Kesava

Reputation: 790

RegExp for Indian Bank Account Number

I need to write a regular expression to check for valid bank account number format of major banks in India. Does anyone know what regular expression check should be? Perhaps I just check to make sure all characters are digits?

Upvotes: 3

Views: 35999

Answers (3)

Tech Agg
Tech Agg

Reputation: 1

Name Field Validation for Account holder name by using Regex in java

public static boolean nameFieldValidation(String name) {
    System.err.println("Name field input ::::" + name);
    logger.info("nameFieldValidation() :: Start :::");
    try {
        if (name == null || name.isEmpty()) {
            return false;
        }
        
        final String NAME_PATTERN = "^(?!\\s|\\.)(?!.*(?:\\s{2}|\\.{2}))[a-zA-Z\\.\\s]+[a-zA-Z]$";

        Pattern pattern = Pattern.compile(NAME_PATTERN);
        Matcher matcher = pattern.matcher(name);
        boolean matches = matcher.matches();
        logger.info(" nameFieldValidation() :: End :::");
        return matches;
        
    } catch (Exception e) {
        logger.error("Error occurred during name verification: :: Exception ::" + e.getMessage());
        return false;
    }
}

Upvotes: 0

degant
degant

Reputation: 4981

RBI dictates certain rules like you've mentioned over Indian Bank Account Number structures (9 - 18).

  • Most of the banks have unique account numbers.
  • Account number length varies from 9 digits to 18 digits.
  • Most of the banks (67 out of 78) have included branch code as part of the account number structure. Some banks have product code as part of the account number structure.
  • 40 out of 78 banks do not have check digit as part of the account number structure.
  • All banks have purely numeric account numbers, except one or two foreign banks.
  • Only in the case of 20 banks, account numbers are formed without any pattern with a unique running serial number.

Indian Bank Account Number Validation Regex:

^\d{9,18}$

A better way to validate would be to select the right bank and then have checks in place as per the bank which have been outlined and analyzed by the RBI here.

Upvotes: 32

Arjun Kesava
Arjun Kesava

Reputation: 790

According to RBI Reserve Bank of India -> The bank should have 9-18 digits

"[0-9]{9,18}"

Upvotes: 4

Related Questions