"^[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}$";
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");
}
}
}