Java examples for java.util.regex:Match Password
check Password by regex
//package com.java2s; import java.util.regex.Matcher; import java.util.regex.Pattern; public class Main { public static boolean checkPassword(String password) { if (isStringEmpty(password)) { return false; }// w w w . j ava 2s . com Pattern p = Pattern.compile("[a-z0-9A-Z_]{6,20}"); Matcher m = p.matcher(password); if (!m.matches()) { return false; } return true; } public static boolean isStringEmpty(String str) { if (str == null || str.length() == 0) { return true; } return false; } }