如何检查pan卡的编辑文本的有效性,如"ABCDE1234F“。我对如何检查验证感到困惑。请帮帮我。我将感谢任何形式的帮助。
发布于 2013-07-17 02:49:15
您可以将正则表达式与模式匹配一起使用
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您可以测试regex @
http://java-regex-tester.appspot.com/
http://docs.oracle.com/javase/tutorial/essential/regex/
更新
另一个是完整的Regular expression validating PAN card number,第五个字符依赖于第四个字符。
发布于 2013-07-17 02:49:26
@ right是对的。您可以使用regex。如果您看到Permanent_account_number(India)的维基条目,您将了解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.`
希望这能有所帮助。
发布于 2019-10-14 16:32:21
这是完美的PAN编号RegEx::
String panNumber = "AAAPL1234C"; // get your editext value here
Pattern pattern = Pattern.compile("[A-Z]{3}[ABCFGHLJPTF]{1}[A-Z]{1}[0-9]{4}[A-Z]{1}");
Matcher matcher = pattern.matcher(panNumber );
// Check if pattern matches
if (matcher.matches()) {
Log.i("Matching","Yes");
}PAN编号的条件如下::
PAN (或PAN编号)是一个十字符长的字母数字唯一标识符。
PAN结构如下:AAAPL1234C
前五个字符是字母(默认为大写),后跟四个数字,最后(第十个)字符是字母。代码的前三个字符是构成从AAA到ZZZ的字母序列的三个字母
第四个字符用于标识卡的持卡器类型。每种持卡器类型由下面列表中的字母唯一定义:
<代码>H118G-政府部门<代码>H219<代码>H120H- HUF (印度教不分家庭)<代码>H221<代码>H122L-地方当局<代码>H223<代码>H124J-人工法人<代码>H225<代码>H126P-个人(所有者)<代码>H227<代码>H128T-信托(AOP)<代码>H229<代码>H130(有限责任partnership) )
PAN的第五个字符是其中之一的第一个字符:
https://stackoverflow.com/questions/17684317
复制相似问题