Javascript IFSC 代码的正则表达式(前四个字母,然后是 7 位数字。)
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/39341176/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Regular expression for IFSC code(first four alphabet and then 7 digit.)
提问by Abhay Kumar
IFSC Code description:
IFSC 代码说明:
- Exact length should be 11
- First 4 alphabets
- Fifth character is 0 (zero)
- Last six characters (usually numeric, but can be alphabetic)
- 确切的长度应该是 11
- 前 4 个字母
- 第五个字符是 0(零)
- 最后六个字符(通常是数字,但可以是字母)
E.g.
例如
SBIN1234567
SBIN1234567
Here is what I tried but its not working.
这是我尝试过但不起作用的方法。
("^[^\s]{4}\d{7}$")
回答by Mudassir Hasan
回答by Satish
According to Indian Financial System Code on wikipedia
IFSC Code Format:
IFSC 代码格式:
1] Exact length should be 11
1] 确切的长度应该是 11
2] First 4 alphabets
2] 前 4 个字母
3] Fifth character is 0 (zero)
3] 第五个字符是 0(零)
4] Last six characters (usually numeric, but can be alphabetic)
4] 最后六个字符(通常是数字,但可以是字母)
Try this:-
尝试这个:-
^[A-Za-z]{4}0[A-Z0-9a-z]{6}$
回答by Rohit Mhatre
As per new rules, RBI changed it's guideline for IFSC Code,
根据新规则,RBI 更改了 IFSC 准则的指南,
New Format for IFSC Code : Eg. ABCD0123456
IFSC 代码的新格式:例如。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.
IFSC 是一个 11 个字符的代码,其中前四个字母字符代表银行名称,后六个字符(通常是数字,但也可以是字母)代表分行。第五个字符是 0(零)并保留供将来使用。NEFT 和 RTGS 系统使用银行 IFS 代码将消息路由到目标银行/分行。
For Code Validation: "^[A-Z]{4}[0][A-Z0-9]{6}$"
对于代码验证: “^[AZ]{4}[0][A-Z0-9]{6}$”
For Java:
对于 Java:
public static boolean isIfscCodeValid(String email)
{
String regExp = "^[A-Z]{4}[0][A-Z0-9]{6}$";
boolean isvalid = false;
if (email.length() > 0) {
isvalid = email.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.
其中 isIfscCodevalid() 是常用的静态方法,它接受用户输入的字符串作为参数(字符串电子邮件),并与 regExp 匹配以进行 IFSC 代码验证,并返回值为 true 或 false。
回答by N?s????? ?
Try this it perfectly works with 4 alphabets followed by 6 or 7 digits
试试这个它完美地适用于 4 个字母后跟 6 或 7 位数字
IFSC Code: SBIN1234567
IFSC Code: HDFC0123654
IFSC Code: SBIN123456
IFSC 代码:SBIN1234567
IFSC 代码:HDFC0123654
IFSC 代码:SBIN123456
$(document).ready(function() {
$.validator.addMethod("ifsc", function(value, element) {
var reg = /^[A-Za-z]{4}[0-9]{6,7}$/;
if (this.optional(element)) {
console.log(value);
console.log(element);
return true;
}
if (value.match(reg)) {
return true;
} else {
return false;
}
}, "Please specify a valid IFSC CODE");
$('#myform').validate({ // initialize the plugin
rules: {
ifsc: {
required: true,
ifsc: true
}
},
submitHandler: function(form) {
alert('valid form submitted');
return false;
}
});
});
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery-validate/1.17.0/jquery.validate.js"></script>
<form id="myform" action="" method="post">
<div>
<label>IFSC CODE</label>
<div>
<input type="text" name="ifsc" value="" id="input-ifsc" />
</div>
</div>
<button type="submit">Register</button>
</form>
IFSC Code description:
IFSC 代码说明:
- Exact length should be 11
- First 4 alphabets
- Fifth character is 0 (zero)
- Last six characters (usually numeric, but can be alphabetic)
- 确切的长度应该是 11
- 前 4 个字母
- 第五个字符是 0(零)
- 最后六个字符(通常是数字,但可以是字母)
IFSC Code: BARB0SANAND
IFSC Code: SBIN0123456
IFSC 代码:BARB0SANAND
IFSC 代码:SBIN0123456
Replace the above JavaScript with the code
用代码替换上面的 JavaScript
var reg = /^[A-Za-z]{4}[0-9]{6,7}$/;
to
到
var reg = /^[A-Za-z]{4}0[A-Z0-9]{6}$/;
回答by Amit Vyas
RBI Changed it's guidline for IFSC code, so please follow this Regex in your code,
RBI 更改了 IFSC 代码的指导方针,因此请在您的代码中遵循此正则表达式,
Regex as per new rules - ^[A-Z]{4}0[A-Z0-9]{6}$
根据新规则的正则表达式 - ^[AZ]{4}0[A-Z0-9]{6}$
Sample IFSC Code as per new Guidline - BARB0SANANDIFSC or Indian Financial System Code is an alpha-numeric code that uniquely identifies a bank-branch participating in the NEFT system. This is an 11 digit code with the first 4 alpha characters representing the bank, and the last 6 characters representing the branch. The 5th character is 0 (zero). IFSC is used by the NEFT system to identify the originating / destination banks / branches and also to route the messages appropriately to the concerned banks / branches.
根据新指南的示例 IFSC 代码 - BARB0SANANDIFSC 或印度金融系统代码是一个字母数字代码,用于唯一标识参与 NEFT 系统的银行分行。这是一个 11 位代码,其中前 4 个字母字符代表银行,后 6 个字符代表分行。第 5 个字符是 0(零)。NEFT 系统使用 IFSC 来识别始发/目的地银行/分行,并将消息适当地路由到相关银行/分行。
回答by Tanisha J
IFSC (Indian Financial System Code) code contains 11 characters alphanumeric unique code and is assigned by RBI to the bank branch to identify each branch of every bank in India. The first four alphabetic is 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 Find more details of IFSC code from http://www.codeforbanks.com/banks/ifsccode-by-branch/
IFSC(印度金融系统代码)代码包含 11 个字符的字母数字唯一代码,由 RBI 分配给银行分行,以识别印度每家银行的每个分行。前四个字母是银行名称,后六个字符(通常是数字,但也可以是字母)代表分行。第五个字符是 0(零),保留供将来使用 从http://www.codeforbanks.com/banks/ifsccode-by-branch/查找 IFSC 代码的更多详细信息
回答by notdrone
回答by Jiten
There are many IFS Codes which are not in such format. For e.g. YESB0CCUB18. You can verify this code by simply putting it on google.
有许多 IFS 代码不是这种格式。例如 YESB0CCUB18。您只需将其放在 google 上即可验证此代码。
I would recommend not to go for a specific validation, simply validate the length or at maximum validate the length and first four to be characters.
我建议不要进行特定验证,只需验证长度或最多验证长度和前四个字符。
Although not related to the question, but in case you want to search IFS Codes, you can refer this website: https://www.bankifscodes.com
虽然与问题无关,但如果你想搜索 IFS Codes,你可以参考这个网站:https: //www.bankifscodes.com