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 first {
- public static void main(String[] args) {
- Scanner scanner = new Scanner(System.in);
- int n = Integer.parseInt(scanner.nextLine());
- String productRegex = "([\\W\\w]+)>(?<numbers>\\d{3})\\|(?<smallWords>[a-z]{3})\\|(?<bigWords>[A-Z]{3})\\|(?<symbols>[^><]{3})<\\1";
- Pattern pattern = Pattern.compile(productRegex);
- for (int i = 0; i < n; i++) {
- String password = scanner.nextLine();
- Matcher matcher = pattern.matcher(password);
- if(matcher.find()){
- System.out.printf("Password: %s%n", matcher.group("numbers") +
- matcher.group("smallWords")+ matcher.group("bigWords") + matcher.group("symbols"));
- }else{
- System.out.println("Try another password!");
- }
- }
- }
- }
Add Comment
Please, Sign In to add comment