Java Postal Code Check IsPostalcode(String str)

Here you can find the source of IsPostalcode(String str)

Description

Is Postalcode

License

Apache License

Declaration

public static boolean IsPostalcode(String str) 

Method Source Code

//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();
    }
}

Related

  1. checkPostalcode(String postalCode)