You're viewing a comment by Eric TF Bat and its responses.

Eric TF Bat Permalink
November 10, 2011, 12:04

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

(why do I need your e-mail?)

(Your twitter name, if you have one. (I'm @pkrumins, btw.))

Type the word "apple": (just to make sure you're a human)

Please preview the comment before submitting to make sure it's OK.