Valid PAN format

Sort by

recency

|

77 Discussions

|

  • + 0 comments

    My solution for Python 3:

    import re
    N = int(input())
    regex_pat = r'^[A-Z]{5}[\d]{4}[A-Z]{1}$'
    for _ in range(N):
        line = input()
        matched_pan = re.search(regex_pat, line)
        if bool(matched_pan):
            print("YES")
        else:
            print("NO")
    
  • + 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')