Sun*_*mar 13 java validation android android-edittext
如何检查pancard的edittext验证,如"ABCDE1234F".我很困惑如何检查这个验证.请帮帮我们.我会感激任何帮助.
Rag*_*dan 33
您可以将正则表达式与模式匹配一起使用
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
Run Code Online (Sandbox Code Playgroud)
你可以测试正则表达式@
http://java-regex-tester.appspot.com/
http://docs.oracle.com/javase/tutorial/essential/regex/
Sho*_*uri 10
@Raghunandan是对的.你可以使用正则表达式.如果您看到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.
Run Code Online (Sandbox Code Playgroud)
`
希望这可以帮助.
这是完美的 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");
}
Run Code Online (Sandbox Code Playgroud)
PAN号码有一些条件如下:
PAN(或 PAN 号)是一个十个字符长的字母数字唯一标识符。
PAN 结构如下:AAAPL1234C :
前五个字符是字母(默认为大写),后跟四个数字,最后(第十个)字符是字母。代码的前三个字符是三个字母,形成从 AAA 到 ZZZ 的字母序列
的第四个字符识别卡的持有人的类型。每种支架类型都由以下列表中的字母唯一定义:
PAN 的第五个字符是以下任一字符的第一个字符:
| 归档时间: |
|
| 查看次数: |
39569 次 |
| 最近记录: |