April 2026
Intermediate
1009 pages
34h 15m
English
In this section, we will show you some useful applications for regular expressions—for form validation, for example.
You will find further examples of regular expressions in this book—for example, in the completeness check in Chapter 13. A check of email addresses is carried out there. This difficult topic is also discussed at http://s-prs.co/v602216.
The verification of zip codes is very simple. A US zip code always consists of five digits. You can check this as follows:
$reg = "/^\d{5}$/";
Additionally a zip code can have a second part with four digits. As separator should be a space or a hyphen possible, after this there are four digits:
$reg = "/^(\d{5})(?:[-\s](\d{4}))?$/";
So you ...
Read now
Unlock full access