Ledger Nano X - The secure hardware wallet
SHARE
TWEET

Untitled

a guest Apr 7th, 2020 215 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. import java.util.Scanner;
  2. import java.util.regex.Matcher;
  3. import java.util.regex.Pattern;
  4.  
  5. public class lqlq {
  6.     public static void main(String[] args) {
  7.         Scanner scanner = new Scanner(System.in);
  8.  
  9.         String regex = "^@#+(?=[A-Z])([A-Za-z0-9]{6,})(?<=[A-Z])@#+$";
  10.         int nums = Integer.parseInt(scanner.nextLine());
  11.         Pattern pattern = Pattern.compile(regex);
  12.  
  13.         while (nums > 0) {
  14.             String input = scanner.nextLine();
  15.             String[] pass = input.split(", ");
  16.  
  17.             for (int i = 0; i < pass.length; i++) {
  18.                 String current = pass[i];
  19.                 Matcher matcher = pattern.matcher(current);
  20.                 if (matcher.find()) {
  21.                     String todo = current;
  22.  
  23.                     String numbers="";
  24.                     for(char c: todo.toCharArray()){
  25.                         if (Character.isDigit(c)) {
  26.                             numbers=numbers+c;
  27.                         }
  28.                     }
  29.                     if(numbers.isEmpty()){
  30.                         System.out.println("Product group: 00");
  31.                     }else {
  32.                         System.out.println("Product group: " + numbers);
  33.                     }
  34.                 } else if (!matcher.find()){
  35.                     System.out.println("Invalid barcode");
  36.                 }
  37.             }
  38.             nums--;
  39.         }
  40.     }
  41. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
Top