emodev

Untitled

Dec 9th, 2018
73
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 1.29 KB | None | 0 0
  1. package pfRetake28Oct_2;
  2.  
  3. import java.io.BufferedReader;
  4. import java.io.IOException;
  5. import java.io.InputStreamReader;
  6. import java.util.Scanner;
  7. import java.util.regex.Matcher;
  8. import java.util.regex.Pattern;
  9.  
  10. public class ChoreWars {
  11.     public static void main(String[] args) throws IOException {
  12.         BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));
  13.  
  14.         while (true) {
  15.             String input = reader.readLine();
  16.             if (input.equals("wife is happy")) {
  17.                 break;
  18.             }
  19.             Pattern dishes = Pattern.compile("(<)([(0-9a-z)]+)(>)+");
  20.             Pattern cleaning = Pattern.compile("(\\[)([(0-9A-Z)]+)(])+");
  21.             Pattern someShit = Pattern.compile("[({)](.*)(})+");
  22.  
  23.             Matcher dishMatcher = dishes.matcher(input);
  24.             Matcher cleanMatcher = cleaning.matcher(input);
  25.             Matcher someShitMatch = someShit.matcher(input);
  26.             if (dishMatcher.find()) {
  27.                 System.out.println(dishMatcher.group(2));
  28.             }
  29.             if (cleanMatcher.find()) {
  30.                 System.out.println(cleanMatcher.group(2));
  31.             }
  32.             if (someShitMatch.find()){
  33.                 System.out.println(someShitMatch.group(1));
  34.             }
  35.  
  36.         }
  37.     }
  38. }
Add Comment
Please, Sign In to add comment