Regular Expressions 101

Community Patterns

Community Library Entry

0

Regular Expression
PCRE (PHP <7.3)

/
(?(DEFINE) (?<bit>[0-1][0-9]{1,2}|2[0-4][0-9]|25[0-5]) ) ( 10\. ((?&bit)\.){2}((?&bit)) )| ( 172\. ( (1[6-9])| (2[0-9])| (3[0-6]) ) \. ((?&bit)\.?+){2} )| ( 192\.168\. ((?&bit)\.?+){2} )
/
x

Description

Check if the given string is a private address

Submitted by Loïc Rameau - 10 years ago