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

Eric TF Bat Permalink
November 10, 2011, 11:59

Nicely done, but #119 is in error as of this writing. It matches a single digit, or two digits, or a one or two followed by two digits under six. That means it won't match its own one-liner number! Or any other useful numbers like 192 and 168 and 127, which come up a lot in IP addresses.

I believe a correct regexp would be:


That matches:

- any one or two digits, optionally starting with "1", so that's 0-9, 00-99, and also 100-199 and (redundantly but harmlessly) 10-19 again
- 200 to 249
- 250 to 255

I haven't run a test, but I'm reasonably confident that it's right.

Comment Responses

November 10, 2011, 12:06

Yours is correct:

$ perl -E 'for (0..255) { $count+=m/^1?\d{1,2}|2[0-4]\d|25[0-5]$/}END{say$count}'

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 "network": (just to make sure you're a human)

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