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

Please support RegExLib Sponsors

Sponsors

Regular Expression Details

Title Test Find IP Address and Subnet
Expression
^((0|1[0-9]{0,2}|2[0-9]{0,1}|2[0-4][0-9]|25[0-5]|[3-9][0-9]{0,1})\.){3}(0|1[0-9]{0,2}|2[0-9]{0,1}|2[0-4][0-9]|25[0-5]|[3-9][0-9]{0,1})(?(\/)\/([0-9]|[1-2][0-9]|3[0-2])|)$
Description
IP Address validation by Vassilis Petroulias + my subnet validation using numbers between 0 and 32
Matches
192.168.0.1 | 192.168.0.1/32 | 255.255.0.0/1
Non-Matches
010.0.0.0 | 192.168.0.1/33 | 256.0.1.55
Author Rating: Not yet rated. Rafael Henrique Kato Assis
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: This one worked for me in Chrome
Name: coolsap
Date: 1/13/2014 10:45:52 PM
Comment:
^(([0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5])\.){3}([0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5])((\/)([1-9]|[1-2][0-9]|3[0-2])){0,1}


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