Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.util.Scanner;
- import java.util.regex.Matcher;
- import java.util.regex.Pattern;
- public class prepTreExam {
- public static void main(String[] args) {
- Scanner scanner = new Scanner(System.in);
- int num = Integer.parseInt(scanner.nextLine());
- Pattern rgx = Pattern.compile("([\\S]+)\\>([0-9]{3})\\|([a-z]{3})\\|([A-Z]{3})\\|([^><]{3})\\<(\\1)");
- for (int i = 0; i < num; i++) {
- String input = scanner.nextLine();
- Matcher macher = rgx.matcher(input);
- if (macher.find()) {
- System.out.printf("Password: %s%s%s%s%n",macher.group(2),macher.group(3),macher.group(4),macher.group(5));
- }else {
- System.out.println("Try another password!");
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement