Category Archives: PHP Functions

Regular Expression (regex or regexp)

Domain Name regular expression

^[a-z0-9]+[a-z0-9-\.]*[a-z0-9]+\.[a-z\.]{2,5}$

IP-address regular expression
This will match any IP-address between 0.0.0.0 to 255.255.255.255

^(([0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5])\.){3}([0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5])$

Decimal value regular expression
Following pattern will match any decimal digit of any size.

^[0-9]+$ » Read more