More computing sins are committed in the name of efficiency (without necessarily achieving it) than for any other single reason - including blind stupidity.
Adding to my previous comment: if you want to allow redundant zeroes, which your regexp does partially, change mine to
/^[01]?\d{1,2}|2[0-4]\d|25[0-5]$/
That's: 0-9, 00-99, 00-09, 000-099, 10-19, 100-199 for the first alternative, then 200-249 for the second and 250-255 for the third as before. It's redundant, but that doesn't matter.
Easier would be combining regexps with a little binary/boolean algebra, but that's straying outside the purity of the topic...
I am being sponsored by Syntress! They bought me an amazing dedicated server to run catonmat on. If you're looking web services, I highly recommend the Syntress guys!
Education Sponsors
I am being sponsored by A-Writer! If you ever need help with essay writing, look no further than A-Writer! They will help you with your writing in as quickly as 3 hours!
Adding to my previous comment: if you want to allow redundant zeroes, which your regexp does partially, change mine to
/^[01]?\d{1,2}|2[0-4]\d|25[0-5]$/
That's: 0-9, 00-99, 00-09, 000-099, 10-19, 100-199 for the first alternative, then 200-249 for the second and 250-255 for the third as before. It's redundant, but that doesn't matter.
Easier would be combining regexps with a little binary/boolean algebra, but that's straying outside the purity of the topic...
Reply To This Comment