Community Patterns

Community Library Entry

2

Regular Expression
Created·2024-10-08 14:03
Flavor·PCRE2 (PHP)

/
^(?:(?:25[0-5]|2[0-4]\d|1\d{2}|\d{2}|\d)(?:\.|$)){4}\b$
/
g
Open regex in editor

Description

Validate an IPv4 address. The addresses are four numbered separated by three dots, and can only have a maximum value of 255 in either octet. Start by trying to validate 172.16.254.1.

Submitted by anonymous