Here you can find the source of IsPostalcode(String str)
public static boolean IsPostalcode(String str)
//package com.java2s; //License from project: Apache License import java.util.regex.Matcher; import java.util.regex.Pattern; public class Main { public static boolean IsPostalcode(String str) { String regex = "^\\d{6}$"; return match(regex, str); }// ww w.ja v a2 s . com private static boolean match(String regex, String str) { Pattern pattern = Pattern.compile(regex); Matcher matcher = pattern.matcher(str); return matcher.matches(); } }