Advertisement
Guest User

Untitled

a guest
Dec 5th, 2019
86
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.80 KB | None | 0 0
  1. import java.util.Scanner;
  2. import java.util.regex.Matcher;
  3. import java.util.regex.Pattern;
  4.  
  5. public class prepTreExam {
  6. public static void main(String[] args) {
  7. Scanner scanner = new Scanner(System.in);
  8.  
  9. int num = Integer.parseInt(scanner.nextLine());
  10.  
  11. Pattern rgx = Pattern.compile("([\\S]+)\\>([0-9]{3})\\|([a-z]{3})\\|([A-Z]{3})\\|([^><]{3})\\<(\\1)");
  12.  
  13. for (int i = 0; i < num; i++) {
  14.  
  15. String input = scanner.nextLine();
  16. Matcher macher = rgx.matcher(input);
  17. if (macher.find()) {
  18. System.out.printf("Password: %s%s%s%s%n",macher.group(2),macher.group(3),macher.group(4),macher.group(5));
  19. }else {
  20. System.out.println("Try another password!");
  21. }
  22.  
  23. }
  24.  
  25.  
  26.  
  27. }
  28. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement