Regular Expressions 101

Community Patterns

Community Library Entry

4

Regular Expression
PCRE (PHP <7.3)

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

Description

Validate IPv4 addresses using PCRE's recursion patterns. A shorter but less efficient alternative to https://regex101.com/r/wZ6oY5/1

Submitted by Captain Haddock - 9 years ago