如何验证PAN卡?
2022-09-03 08:32:19
如何检查像“ABCDE1234F”这样的平移卡的编辑文本的验证。我对如何检查对此的验证感到困惑。请帮帮我伙计们。我将不胜感激任何帮助。
如何检查像“ABCDE1234F”这样的平移卡的编辑文本的验证。我对如何检查对此的验证感到困惑。请帮帮我伙计们。我将不胜感激任何帮助。
您可以将正则表达式与模式匹配结合使用
String s = "ABCDE1234F"; // get your editext value here
Pattern pattern = Pattern.compile("[A-Z]{5}[0-9]{4}[A-Z]{1}");
Matcher matcher = pattern.matcher(s);
// Check if pattern matches
if (matcher.matches()) {
Log.i("Matching","Yes");
}
// [A-Z]{5} - match five literals which can be A to Z
// [0-9]{4} - followed by 4 numbers 0 to 9
// [A-Z]{1} - followed by one literal which can A to Z
您可以测试正则表达式@
http://java-regex-tester.appspot.com/
http://docs.oracle.com/javase/tutorial/essential/regex/
更新
另一个完全正则表达式验证 PAN 卡号的第 5 个字符取决于第 4 个字符。
@Raghunandan是对的。您可以使用正则表达式。如果你看到Permanent_account_number(印度)的维基条目,你就会明白PAN卡号形成的含义。您可以使用该模式来检查其有效性。相关部分如下:
PAN structure is as follows: AAAAA9999A: First five characters are letters, next 4 numerals, last character letter.
1) The first three letters are sequence of alphabets from AAA to zzz
2) The fourth character informs about the type of holder of the Card. Each assesse is unique:`
C — Company
P — Person
H — HUF(Hindu Undivided Family)
F — Firm
A — Association of Persons (AOP)
T — AOP (Trust)
B — Body of Individuals (BOI)
L — Local Authority
J — Artificial Judicial Person
G — Government
3) The fifth character of the PAN is the first character
(a) of the surname / last name of the person, in the case of
a "Personal" PAN card, where the fourth character is "P" or
(b) of the name of the Entity/ Trust/ Society/ Organisation
in the case of Company/ HUF/ Firm/ AOP/ BOI/ Local Authority/ Artificial Jurdical Person/ Govt,
where the fourth character is "C","H","F","A","T","B","L","J","G".
4) The last character is a alphabetic check digit.
`
希望这有帮助。