check Password by regex - Android java.util.regex

Android examples for java.util.regex:Password Pattern

Description

check Password by regex

Demo Code


//package com.java2s;
import java.util.regex.Matcher;
import java.util.regex.Pattern;

public class Main {
    public static boolean checkPassword(String password) {
        String passwordRegex = "^[a-zA-Z0-9!@.#$%^&*?_~]{6,16}$";
        Pattern p = Pattern.compile(passwordRegex);
        Matcher m = p.matcher(password);
        return m.matches();
    }//from www .j a  v  a 2 s  .  c  om
}

Related Tutorials