首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >如何验证PAN卡?

如何验证PAN卡?
EN

Stack Overflow用户
提问于 2013-07-17 02:30:34
回答 16查看 60.2K关注 0票数 16

如何检查pan卡的编辑文本的有效性,如"ABCDE1234F“。我对如何检查验证感到困惑。请帮帮我。我将感谢任何形式的帮助。

EN

回答 16

Stack Overflow用户

回答已采纳

发布于 2013-07-17 02:49:15

您可以将正则表达式与模式匹配一起使用

代码语言:javascript
复制
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,第五个字符依赖于第四个字符。

票数 41
EN

Stack Overflow用户

发布于 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.

代码语言:javascript
复制
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.

`

希望这能有所帮助。

票数 10
EN

Stack Overflow用户

发布于 2019-10-14 16:32:21

这是完美的PAN编号RegEx:

代码语言:javascript
复制
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的字母序列的三个字母

第四个字符用于标识卡的持卡器类型。每种持卡器类型由下面列表中的字母唯一定义:

  • A -个人协会
  • B-个人团体(BOI)
  • C -公司
  • F -公司

<代码>H118G-政府部门<代码>H219<代码>H120H- HUF (印度教不分家庭)<代码>H221<代码>H122L-地方当局<代码>H223<代码>H124J-人工法人<代码>H225<代码>H126P-个人(所有者)<代码>H227<代码>H128T-信托(AOP)<代码>H229<代码>H130(有限责任partnership) )

PAN的第五个字符是其中之一的第一个字符:

  • 表示个人的姓氏或姓氏,如属“个人”PAN卡,则为实体、信托、社会或组织名称的"P“或
  • ;如属公司/HUF/firm/AOP/ trust /BOI/local authority/artificial法人/政府,则为"C”、"H“、"F”、"A“、"T”、"B“、"L”、"J“。“G”。最后(第十个)字符是一个字母数字,用作校验和以验证
票数 6
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/17684317

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档