Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public static void main(String[] args) throws IOException {
- BufferedReader rd = new BufferedReader(new InputStreamReader(System.in));
- int n = Integer.parseInt(rd.readLine());
- Pattern pattern = Pattern.compile("!([A-Z][a-z]{2,})!:\\[([A-Za-z]{8,})]");
- for (int i = 0; i < n; i++) {
- String str = rd.readLine();
- Matcher matcher = pattern.matcher(str);
- if (matcher.find()) {
- List<Integer> list = Stream.of(matcher.group(2).split("")).map(s -> (int) s.charAt(0)).collect(Collectors.toList());
- String print = list.toString();
- print = print.replaceAll("[\\[\\],]", "");
- System.out.println(matcher.group(1) + ": " + print);
- } else {
- System.out.println("The message is invalid");
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement