Java tutorial
public class MainClass { public static void main(String args[]) { String addr = "my Address 12345"; String namePattern = "([A-Za-z])+ (([A-Za-z])+\\.? )?([A-Za-z])+\\s*"; String zipCodePattern = "\\d{5}(-\\d{4})?"; String addressPattern = "^" + namePattern + "\\w+ .*, \\w+ " + zipCodePattern + "$"; System.out.println(addr.matches(addressPattern)); } }