Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package pfRetake28Oct_2;
- import java.io.BufferedReader;
- import java.io.IOException;
- import java.io.InputStreamReader;
- import java.util.Scanner;
- import java.util.regex.Matcher;
- import java.util.regex.Pattern;
- public class ChoreWars {
- public static void main(String[] args) throws IOException {
- BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));
- while (true) {
- String input = reader.readLine();
- if (input.equals("wife is happy")) {
- break;
- }
- Pattern dishes = Pattern.compile("(<)([(0-9a-z)]+)(>)+");
- Pattern cleaning = Pattern.compile("(\\[)([(0-9A-Z)]+)(])+");
- Pattern someShit = Pattern.compile("[({)](.*)(})+");
- Matcher dishMatcher = dishes.matcher(input);
- Matcher cleanMatcher = cleaning.matcher(input);
- Matcher someShitMatch = someShit.matcher(input);
- if (dishMatcher.find()) {
- System.out.println(dishMatcher.group(2));
- }
- if (cleanMatcher.find()) {
- System.out.println(cleanMatcher.group(2));
- }
- if (someShitMatch.find()){
- System.out.println(someShitMatch.group(1));
- }
- }
- }
- }
Add Comment
Please, Sign In to add comment