Java tutorial
//package com.java2s; import java.util.regex.Matcher; import java.util.regex.Pattern; public class Main { public static boolean validatePassWord(String password) { boolean flag; try { String check = "^[A-Za-z0-9]{6,16}$"; Pattern regex = Pattern.compile(check); Matcher matcher = regex.matcher(password); flag = matcher.matches(); } catch (Exception e) { flag = false; } return flag; } }