Community Patterns

Community Library Entry

0

Regular Expression
Created·2022-01-25 22:44
Flavor·PCRE2 (PHP)

/
^(25[0-5]|2[0-4][0-9]|1[0-9][0-9]|0?[1-9][0-9]?|0?[0-9]?[1-9])(.(25[0-5]|2[0-4][0-9]|[0-1]?[0-9]?[0-9])){2}.(25[0-5]|2[0-4][0-9]|1[0-9][0-9]|0?[1-9][0-9]?|0?[0-9]?[1-9])$
/
gm
Open regex in editor

Description

When validating an IPv4 address I often have to reject devices that the first and last octet are 0.

Submitted by John Cutburth