RegExLib.com - The first Regular Expression Library on the Web!

Please support RegExLib Sponsors

Sponsors

Regular Expression Details

Title Test Find Private IP address
Expression
(^10\.)|(^172\.1[6-9]\.)|(^172\.2[0-9]\.)|(^172\.3[0-1]\.)|(^192\.168\.)|(^127\.0\.0\.1)
Description
It matches private IP addresses. Private IP addresses (as defined by RFC 1918) are not routable on public Internet. This would help if you want to grant some previlege only to the users from within local network. ***Importnat*** This pattern assumes that the input is a valid IP address. You many need to make sure the input is a valid IP address.
Matches
10.12.0.19 | 172.21.0.23 | 192.168.0.2
Non-Matches
222.12.3.24 | 172.12.0.12
Author Rating: Not yet rated. Mahesh Ramakrishnan
Source
Your Rating
Bad Good

Enter New Comment

Title

Name

Comment

Spammers suck - we apologize. Please enter the text shown below to enable your comment (not case sensitive - try as many times as you need to if the first ones are too hard):

Existing User Comments

Title: Small improvement
Name: Daniel Serodio
Date: 7/18/2011 5:48:28 PM
Comment:
The "beginning" (caret) character can be factored out, and you don't need so many parenthesis because "alternation" (pipe) has the lowest precedence of all regexp chars: ^(10\.|172\.1[6-9]\.|172\.2[0-9]\.|172\.3[0-1]\.|192\.168\.|127\.0\.0\.1).*


Copyright © 2001-2024, RegexAdvice.com | ASP.NET Tutorials