Regular Expressions 101

Community Patterns

IP Address Validation Express

1

Regular Expression
PCRE (PHP <7.3)

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

Description

This is an accurate IP Address validation express that matches 1.1.1.1 to 255.255.255.255. Enjoy the code and pass it on to someone else in need.

"With practice you have no choice but to improve." "A logical mind has no limits to understanding."

Submitted by anonymous - 3 years ago