Thursday, January 3, 2013

regex for IP address matching

If you're looking to splice an IP address from a document and there is a 100% chance that the IP address is properly formatted then why the F**k would you want a regex like this:

"^(([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])quot;
In the worst case the regex might look like:

"^([0-9]{1,3})\.([0-9]{1,3})\.([0-9]{1,3})\.([0-9]{1,3})$"
But even this is abusive.

No comments:

Post a Comment

another bad day for open source

One of the hallmarks of a good open source project is just how complicated it is to install, configure and maintain. Happily gitlab and the ...