Posted By

Scooter on 07/26/08


Versions (?)

Who likes this?

3 people have marked this snippet as a favorite


Validate IP Address

 / Published in: Regular Expression


A more robust and elegant regular expression for checking IP addresses than the ones previously available here on Snipplr. Each octet is guaranteed a valid number between 0 and 255, and the three trailing octets are grouped to minimize pattern length. See the corresponding blog post for ASP and PHP functions that implement this pattern. (Also available here on Snipplr.)

  1. "^([1]?\d{1,2}|2[0-4]{1}\d{1}|25[0-5]{1})(\.([1]?\d{1,2}|2[0-4]{1}\d{1}|25[0-5]{1})){3}$

Report this snippet  

You need to login to post a comment.