Java tutorial
//package com.java2s; import java.util.regex.Matcher; import java.util.regex.Pattern; public class Main { public static boolean isValidPasswd(String passwd) { if (isEmpty(passwd)) { return false; } Pattern p = Pattern.compile("[a-zA-Z0-9]{6,16}"); Matcher m = p.matcher(passwd); return m.matches(); } public static boolean isEmpty(String string) { return string == null || string.length() == 0; } }