This Example describes the way of matching Zip code with the regular expression .For this we are going to make program named Matching_Zipcode.java. The steps involved in program Matching_Zipcode.java are described below:-
String zipCode = "\\d{5}(-\\d{4})?":-This is the regular expression use to match with Zip code.
matchZip("45643-44435"):-Defining Zip code which is to be matched with the regular expression
Matching_Zipcode.java
|
Output of the program:-
| MATCH : Zip code is :45643 regex for the Zip code is : \d{5}(-\d{4})? NO MATCH: Zip code is:45643-44435 regex for the Zip code is: \d{5}(-\d{4})? |
If you are facing any programming issue, such as compilation errors or not able to find the code you are looking for.
Ask your questions, our development team will try to give answers to your questions.
Ask Questions? Discuss: Matching Zip code using regular expression
Post your Comment