Regular Expressions 101

Community Patterns

Dotted-decimal IPv4 address

0

Regular Expression
PCRE (PHP <7.3)

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

Description

Validates an IPv4 address for use as a URI host as defined in RFC-3986.

Submitted by ezzatron - 10 years ago