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 isCode(String strCode) { String strPattern = "^[0-9]{6}"; Pattern p = Pattern.compile(strPattern); Matcher m = p.matcher(strCode); return m.matches(); } }