Java tutorial
//package com.java2s; import java.util.regex.Matcher; import java.util.regex.Pattern; public class Main { public static boolean checkPassword(String pwd) { String strPattern = "[A-Za-z0-9]{6,12}"; Pattern p = Pattern.compile(strPattern); Matcher m = p.matcher(pwd); return m.matches(); } }