PHP uses two types of functions that will work with regular expressions. One type of function is the preg set of functions, which include preg_match and preg_match_all these functions work with the PCRE Library.
The second type is an old form of regular expression which is compatible with POSIX called ereg and eregi which is now depreciated since PHP 5.3.
For this tutorial all the examples will make use of either the preg_match or preg_match_all and PCRE compatible regex patterns.
Matching a Valid Email Address
Matching a string between 4 and 128 characters
Matching an integer between 1 and 16 characters in length
Matching Content between any given HTML tag with attributes
Matching a Valid http:// URL
Matching a US Phone Number
Matching a UK Phone Number
Matching a UK Postal code
Matching a US Zip Code
Matching an IPv4 IP address
Matching an IPv6 IP address