Skip to main content
added 116 characters in body
Source Link
Neil
  • 177.3k
  • 12
  • 74
  • 281

Retina, 4242 41 bytes

~(K`

255*
|'|L$`
$.`
.+
^["^(($&"|'|]")\.?\b){34}($&)$"L$`
$.`

Try it online! PortTry it online! Based on a previous version of @nwellnhof's Perl 6 answer, but 1 byte saved by stealing the \.?\b trick from @Deadcode's answer. Explanation:

K`

Clear the work area.

255*

Insert 255 characters.

|'|L$`["^(("|'|]")\.?\b){4}$"L$`
$.`

Generate the range 0..255 separated with |s.

.+
^(($&)\.){3}($&)$

Build, prefixed with ^((, and suffixed with )\.?\b){4}$, thus building the regular expression ^((0|1|...255)\.?\b){34}(0|1|...255)$.

~(

Evaluate that on the original input.

Retina, 42 bytes

~(K`

255*
|'|L$`
$.`
.+
^(($&)\.){3}($&)$

Try it online! Port of @nwellnhof's Perl 6 answer. Explanation:

K`

Clear the work area.

255*

Insert 255 characters.

|'|L$`
$.`

Generate the range 0..255 separated with |s.

.+
^(($&)\.){3}($&)$

Build the regular expression ^((0|1|...255)\.){3}(0|1|...255)$.

~(

Evaluate that on the original input.

Retina, 42 41 bytes

~(K`

255*
["^(("|'|]")\.?\b){4}$"L$`
$.`

Try it online! Based on a previous version of @nwellnhof's Perl 6 answer, but 1 byte saved by stealing the \.?\b trick from @Deadcode's answer. Explanation:

K`

Clear the work area.

255*

Insert 255 characters.

["^(("|'|]")\.?\b){4}$"L$`
$.`

Generate the range 0..255 separated with |s, prefixed with ^((, and suffixed with )\.?\b){4}$, thus building the regular expression ^((0|1|...255)\.?\b){4}$.

~(

Evaluate that on the original input.

Source Link
Neil
  • 177.3k
  • 12
  • 74
  • 281

Retina, 42 bytes

~(K`

255*
|'|L$`
$.`
.+
^(($&)\.){3}($&)$

Try it online! Port of @nwellnhof's Perl 6 answer. Explanation:

K`

Clear the work area.

255*

Insert 255 characters.

|'|L$`
$.`

Generate the range 0..255 separated with |s.

.+
^(($&)\.){3}($&)$

Build the regular expression ^((0|1|...255)\.){3}(0|1|...255)$.

~(

Evaluate that on the original input.