Main.java Source code

Java tutorial

Introduction

Here is the source code for Main.java

Source

public class Main {
    public static void main(String args[]) {
        String addr = "street 124 a0a";
        String nameToken = "\\p{Upper}(\\p{Lower}+\\s?)";
        String namePattern = "(" + nameToken + "){2,3}";
        String zipCodePattern = "\\d{5}(-\\d{4})?";
        String addressPattern = "^" + namePattern + "\\w+ .*, \\w+ " + zipCodePattern + "$";
        System.out.println(addr.matches(addressPattern));

    }
}