Regular Expressions 101

Community Patterns

1...34567...886

Private IPv4

1

Regular Expression
PCRE2 (PHP >=7.3)

/
^((10|127)(\.(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?))|169\.254|192\.168|172\.(2[0-9]|1[6-9]|3[0-1]))(\.(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)){2}$
/
gm

Description

Match only Public IPv4

Does not match Private IPv4 and test Nets

Submitted by anonymous - 2 months ago