Java tutorial
//package com.java2s; //License from project: Apache License import java.util.regex.Matcher; import java.util.regex.Pattern; public class Main { public static boolean isPassCode(String strCode) { String strPattern = "^[0-9a-zA-Z@*%#()><!_~]{6,12}"; Pattern p = Pattern.compile(strPattern); Matcher m = p.matcher(strCode); return m.matches(); } }