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

Please support RegExLib Sponsors

Sponsors

Regular Expression Details

Title Test Find Valid IP
Expression
\b(((?!\d\d\d)\d+|1\d\d|2[0-4]\d|25[0-5])(\b|\.)){4}
Description
match valid ip
Matches
192.168.0.1 | 10.0.0.255 | 211.100.0.0
Non-Matches
192.256.0.1 | 10.0.0.256 | 211.100.0.1000
Author Rating: The rating for this expression. sswater shi
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: "{2,4}" is not right
Name: sswater shi
Date: 12/1/2005 7:48:11 PM
Comment:
"{2,4}" is not right


Title: Why 127.1 should be regarded as valid ip?
Name: sswater shi
Date: 12/1/2005 7:39:06 PM
Comment:
Bacause there is a "{4}" in my pattern, if 127.1 should be regarded as valid ip, "{4}" should be "{2,4}" instead. I'm sorry but why 127.1 should be regarded as valid ip?


Title: Fails to match 127.1 which is a valid IP
Name: Randal L. Schwartz
Date: 12/1/2005 9:47:17 AM
Comment:
Fails to match valid IPs that don't consist of four numbers. You guys really oughta go read specs instead of believing other coders.


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