Valid PAN format

  • + 0 comments

    For java 8

    import java.io.; import java.util.; import java.util.regex.Matcher; import java.util.regex.Pattern;

    public class Solution {

    public static void main(String[] args) {
        /* Enter your code here. Read input from STDIN. Print output to STDOUT. Your class should be named Solution. */
    
        Scanner sc = new Scanner(System.in);
        int testedNumber = sc.nextInt();
        sc.nextLine();
        ArrayList<String> al = new ArrayList<>();
        for(int i=0;i<testedNumber;i++){
            al.add(sc.nextLine());
        }
    
        String regex = "[A-Z]{5}[0-9]{4}[A-Z]{1}";
        Pattern p =Pattern.compile(regex);
        boolean b=false;
        for(int i=0;i<al.size();i++){
    
    
        Matcher m=p.matcher(al.get(i));
        b=m.matches();
        if(b){
            System.out.println("YES");
        }
        else {
            System.out.println("NO");
        }
        }
    
    
    
    
    
    
    
    }
    

    }