Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package com.company.softuni;
- import java.util.Scanner;
- import java.util.regex.Matcher;
- import java.util.regex.Pattern;
- public class Main3 {
- public static void main(String[] args) {
- Pattern pattern = Pattern.compile("^@#+[A-Z][a-zA-Z0-9]{4,}[A-Z]@#+$");
- Scanner scanner = new Scanner(System.in);
- int n = Integer.parseInt(scanner.nextLine());
- for (int i = 0; i < n; i++) {
- String line = scanner.nextLine();
- Matcher matcher = pattern.matcher(line);
- if (matcher.matches()) {
- line = line.replaceAll("\\D+","");
- }
- if (line.isEmpty()) {
- System.out.println("Product group: 00");
- } else {
- System.out.println("Product group: " + line);
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement