我看过PAN103正常表达式的this question和this blog。 [A-Z]{5}[0-9]{4}[A-Z]{1}
。但是我的问题比这个扩大了一点点。验证PAN卡号的正则表达式
在PAN卡号码:
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.
我想正则表达式要在此基础上检查。由于我得到了该人的姓名,或者在另一个EditText中获得了该组织名称,所以我需要进一步验证第4封和第5封信。
它原来是[A-Z]{3}[C,H,F,A,T,B,L,J,G,P]{1}**something for the fifth character**[0-9]{4}[A-Z]{1}
我无法弄清楚如何说东西已被写入。
以编程方式,它可以完成,someone has done it in rails但它可以通过正则表达式吗?怎么样?
做尝试(P | [C,H,F,A,T,B,L,J,G]) –
不能能够理解第三点。有多少个字符? –
@AvinashRaj如果PAN卡号中的第四个字符是P,那么第五个字符将是您姓的第一个字母,例如。如果你是Avinash Raj,你的pancard数字的第4个字符将是P个人,第5个字符将是Raj的R.而如果PAN卡属于一个组织,比如说一家公司,那么第四个字符就是公司的C,第五个字母是公司名称的第一个字母,例如,如果有一家公司叫做“微软公司”,那么公司的第四个字符是“C”,第五个字符是微软的“M”。 – inquisitive