Regular Expressions 101

Community Patterns

Community Library Entry

0

Regular Expression
ECMAScript (JavaScript)

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

Description

This will match valid IP addresses which are listed in RFC1918.

  • 127.0.0.0 - 127.255.255.255
  • 10.0.0.0 - 10.255.255.255
  • 192.168.0.0 - 192.168.255.255
  • 172.16.0.0 - 172.31.255.255
Submitted by anonymous - 4 years ago