- The first Regular Expression Library on the Web!

Please support RegExLib Sponsors


Regular Expression Details

Title Test Find Accurate IP address verification
Accurate IP address verification... Each numeric part of an IP address must be between 0 and 255. All patterns I have seen on the net cover this range but they allow leading zeros. The valid cases are: * 0 * 1, 10-19 and 100-199 aka 1[0-9]{0,2} * 2 and 20-29 aka 2[0-9]? * 200-249 aka 2[0-4][0-9] * 250-255 aka 25[0-5] * 3-9 and 30-99 aka [3-9][0-9]?
Matches | |
Non-Matches | |
Author Rating: The rating for this expression. Vassilis Petroulias
Your Rating
Bad Good

Enter New 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: Allows invalid IP addresses
Name: Dan R
Date: 2/24/2010 12:59:09 PM
Allows and While may be a valid IP (depending on mask) will never be valid, nor would

Title: General concept for long version patterns
Name: Vassilis Petroulias
Date: 12/30/2005 4:46:04 AM
Thank you for your comment. In general I use long version and syntax when I distribute patterns while this way regex newbies can easily visualize the logic of a pattern. On the other hand experience developers can short them at dead time.

Title: A shorter version
Name: Jesse Houwing
Date: 12/29/2005 7:13:45 PM
This does the same, but is a little shorter. I personally find it easier to read (though the part covering 0-99 is arguably harder). ^(([1-9]?[0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5])[.]){3}([1-9]?[0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5])$

Copyright © 2001-2024, | ASP.NET Tutorials