Regular Expressions 101

Community Patterns

Match RFC1918 And Localhost

1

Regular Expression
PCRE2 (PHP >=7.3)

/
^(?:(?:10\.\d{1,3}\.\d{1,3}\.\d{1,3}|172\.(?:(?:1[6-9])|(?:2[0-9])|(?:3[0-1]))\.\d{1,3}\.\d{1,3}|192\.168\.\d{1,3}\.\d{1,3}|127\.\d{1,3}\.\d{1,3}\.\d{1,3})(?::\d{1,5})?)$
/
gm

Description

Matches RFC1918 and Localhost ips.

Submitted by nck - 9 months ago