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

Please support RegExLib Sponsors

Sponsors

Regular Expression Details

Title Test Find IP validator
Expression
/^(?:(?:1\d?\d|[1-9]?\d|2[0-4]\d|25[0-5])\.){3}(?:1\d?\d|[1-9]?\d|2[0-4]\d|25[0-5])$/
Description
It matches an IP address only in the correct format. There was a previous regex send which matches 192.168.01.2 but this code won't match preceeding 0's
Matches
192.168.1.2 | 127.0.0.1
Non-Matches
192.168.01.2 | 1921.68.1.2
Author Rating: The rating for this expression. snabbi
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: nope, it isn't perfect
Name: howang
Date: 11/7/2006 9:04:23 PM
Comment:
It matches network address and boardcast address too! And it matches private address such as 192.168.x.x 10.x.x.x and 172.16-19.x.x , the worst case is, it even match a loopback address 127.0.0.1! Those ip above are invalid on the Internet!


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