Valid PAN format

Sort by

recency

|

76 Discussions

|

  • + 0 comments

    Java 15

    import java.io.*;
    import java.util.*;
    import java.util.regex.Pattern;
    import java.util.regex.Matcher;
    public class Solution {
        public static void main(String[] args) {
            Scanner scanner = new Scanner(System.in);
            int n = Integer.parseInt(scanner.nextLine());
            Pattern pattern = Pattern.compile("^[A-Z]{5}\\d{4}[A-Z]$");
            for (int i=0;i<n;i++)
            {   Matcher matcher = pattern.matcher(scanner.nextLine());
                if (matcher.find()) System.out.println("YES");
                else System.out.println("NO");
            }
        }
    }
    
  • + 0 comments

    Javascript:

    const lines = input.split("\n");
    lines.shift();
    
    lines.forEach((line) => {
       if (!line) {
          return;
       }
    
       const status = line.match(/^[A-Z]{5}\d{4}[A-Z]$/) ? 'YES' : 'NO';
       console.log(status);
    })
    
  • + 0 comments

    java solution

    import java.io.*;
    import java.util.*;
    import java.util.regex.Pattern;
    import java.util.regex.Matcher;
    
    public class Solution {
    
        public static void main(String[] args) {
            Scanner scanner = new Scanner(System.in);
            Pattern pattern = Pattern.compile("[A-Z]{5}\\d{4}[A-Z]");
            int n = Integer.valueOf(scanner.nextLine());
            for (int i = 0; i < n; i++) {
                Matcher matcher = pattern.matcher(scanner.nextLine());
                String result = (matcher.find())? "YES" : "NO";
                System.out.println(result);
            }
        }
    }
    
  • + 0 comments
    import re
    
    regex = re.compile(r'^[A-Z]{5}[0-9]{4}[A-Z]$')
    
    
    for i in range(int(input())):
        if regex.match(input()):
            print('YES')
        else:
            print('NO')
    
  • + 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");
        }
        }
    
    
    
    
    
    
    
    }
    

    }