Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package br.com.jonasdsg.app;
- import java.util.Scanner;
- import java.util.regex.Pattern;
- public class PasswordCheck {
- public static void main(String[] args) {
- Scanner teclado = new Scanner(System.in);
- System.out.print("Digite a senha: ");
- String senha = teclado.nextLine();
- teclado.close();
- Boolean check =
- Pattern.compile("[A-Z]+").matcher(senha).find() // Verifica caracteres Maiusculos
- && Pattern.compile("[a-z]+").matcher(senha).find() // Verifica caracteres Minusculos
- && Pattern.compile("!|@|#|\\$|%|\\^|&|\\*|\\(|\\)|-|\\+").matcher(senha).find() // Verifica os caracteres especiais
- && senha.length()>=6;
- System.out.println("Password "+ ( check ? "Válido" : "Inválido"));
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement