Click here to Skip to main content
15,029,369 members
Please Sign up or sign in to vote.
1.27/5 (5 votes)
See more:
Hi;
I need Regular Expression for validating PAN No.
Thanks
Posted
Updated 28-Oct-20 23:30pm
Comments
vipan.net 27-Feb-16 0:20am
   
check link for answer
http://www.dotnetfunda.com/codes/show/1522/validate-indian-pan-number-using-regular-expression
Nirav Prabtani 15-Feb-17 2:56am
   
What have you tried ? Dont ask for your home work that you don't want to do

PAN has specific format,

XXXXX9999X where X is a alphabatic character and 9 is a numeric digit.


<asp:regularexpressionvalidator id="RegularExpressionValidator1" runat="server" xmlns:asp="#unknown">
ErrorMessage="Please check PAN Format" ControlToValidate="txtMVENXvarPan0"
ValidationExpression="[A-Za-z]{5}\d{4}[A-Za-z]{1}">
   
Comments
Naresh Warbhe 24-Nov-12 8:17am
   
It works perfectly
Please see the following link ->

pan-Number

Pan-Number
   
As Per as PAN (Permanant account no) I have assume that,
Pan no must contain 10 chars,
among from 10 char each char either should be Alphabetic uppercase char or numeric.

So from my assumption constructed regex is.

^[A-Z0-9]{10}$

and for complete understanding on Regex you could have this article to be useful,
The 30 Minute Regex Tutorial[^]

Please vote and Accept Answer if it Helped.
   
"^[A-Z]{5}+[0-9]{4}+[A-Z]{1}$"

Note: Please look below expression-

----------------------------------------------

package Programs;
import java.util.Scanner;
public class ValidatingEmail {
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
System.out.println("Enter your Pan-id: ");
String phone = sc.next();
String regex = "^[A-Z]{5}[0-9]{4}[A-Z]{1}$";
//Matching the given phone number with regular expression
boolean result = phone.matches(regex);
if(result) {
System.out.println("Given Pan-id is valid");
} else {
System.out.println("Given Pan-id is not valid");
}
}
}
   
v2
Comments
Patrice T 29-Oct-20 5:03am
   
10 years too late ans answer is wrong.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)




CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900