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

Please support RegExLib Sponsors

Sponsors

Regular Expression Details

Title Test Find Pattern Title
Expression
^(((((25[0-5]|2[0-4][0-9]|[0-1]{1}[0-9]{2}|[1-9]{1}[0-9]{1}|[1-9])\.(25[0-5]|2[0-4][0-9]|[0-1]{1}[0-9]{2}|[1-9]{1}[0-9]{1}|[1-9]|0)\.(25[0-5]|2[0-4][0-9]|[0-1]{1}[0-9]{2}|[1-9]{1}[0-9]{1}|[1-9]|0)\.(25[0-5]|2[0-4][0-9]|[0-1]{1}[0-9]{2}|[1-9]{1}[0-9]{1}|[0-9])-(25[0-5]|2[0-4][0-9]|[0-1]{1}[0-9]{2}|[1-9]{1}[0-9]{1}|[1-9])\.(25[0-5]|2[0-4][0-9]|[0-1]{1}[0-9]{2}|[1-9]{1}[0-9]{1}|[1-9]|0)\.(25[0-5]|2[0-4][0-9]|[0-1]{1}[0-9]{2}|[1-9]{1}[0-9]{1}|[1-9]|0)\.(25[0-5]|2[0-4][0-9]|[0-1]{1}[0-9]{2}|[1-9]{1}[0-9]{1}|[0-9]))|((25[0-5]|2[0-4][0-9]|[0-1]{1}[0-9]{2}|[1-9]{1}[0-9]{1}|[1-9])\.(25[0-5]|2[0-4][0-9]|[0-1]{1}[0-9]{2}|[1-9]{1}[0-9]{1}|[1-9]|0)\.(25[0-5]|2[0-4][0-9]|[0-1]{1}[0-9]{2}|[1-9]{1}[0-9]{1}|[1-9]|0)\.(25[0-5]|2[0-4][0-9]|[0-1]{1}[0-9]{2}|[1-9]{1}[0-9]{1}|[0-9]))),)*)(((25[0-5]|2[0-4][0-9]|[0-1]{1}[0-9]{2}|[1-9]{1}[0-9]{1}|[1-9])\.(25[0-5]|2[0-4][0-9]|[0-1]{1}[0-9]{2}|[1-9]{1}[0-9]{1}|[1-
Description
Matches comma-separated list of IP address and IP ranges. E.g. 192.168.101.1-192.168.101.255,192.168.102.12
Matches
192.168.101.1 | 192.168.101.1-192.168.101.255 | 192.168.101.1-192.168.101.255,192.168.102.12
Non-Matches
999.168.101.1 | 192.168.101.1- | -192.168.101.255
Author Rating: The rating for this expression. Gregory Entin
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: Incomplete Regex
Name: Ravi
Date: 7/7/2006 5:41:41 AM
Comment:
This regex is incomplete. How do it ends? Please specify.


Title: Regex incomplete
Name: ShArDiCk
Date: 8/25/2005 11:42:21 AM
Comment:
This regexp is incomplete.. How do it ends?


Title: BTW
Name: Jonathan
Date: 10/8/2003 6:41:51 PM
Comment:
By the way, the pattern described above (25[0-5]|2[0-4][0-9]|1[0-9]{2}|[1-9]?[0-9]) matches substrings "0" to "255". But the pattern (25[0-5]|2[0-4][0-9]|1[0-9]{1,2}|[1-9]) matches "1" to "255". So, if you want for example to restrict *.*.*.0 addresses you would use the syntax (<0_to_255>\.){3}(<1_to_255>), so as to get ((25[0-5]|2[0-4][0-9]|1[0-9]{2}|[1-9]?[0-9])\.){3}(25[0-5]|2[0-4][0-9]|1[0-9]{1,2}|[1-9])


Title: Grouping...
Name: Jonathan
Date: 10/8/2003 6:27:24 PM
Comment:
Try to group your sub-masks... for an IPv4 address, you would get: (<bytemask>)(\.<bytemask>){3} Same thing for use of classes for byte masks - compare: yours: (25[0-5]|2[0-4][0-9]|[0-1]{1}[0-9]{2}|[1-9]{1}[0-9]{1}|[1-9]) better: (25[0-5]|2[0-4][0-9]|1[0-9]{2}|[1-9]?[0-9]) Also, leading "0" are used for octal representations of a byte; one is allowed through the third byte of your typical IPv4 sub-mask, but not for other bytes. For instance: 192.168.032.1, which is treated as 192.168.26.1, would match; but not 192.168.1.048


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