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:
I need Regular Expression for validating PAN No.
Updated 28-Oct-20 23:30pm
Comments 27-Feb-16 0:20am
check link for answer
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"
Naresh Warbhe 24-Nov-12 8:17am
It works perfectly
Please see the following link ->


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.


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.

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.out.println("Enter your Pan-id: ");
String phone =;
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");
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