3v4l.org

run code in 200+ php & hhvm versions
Bugs & Features
<?php $tests=[ "207.142.131.005", // 207.142.XXX.XXX "2001:0db8:0000:08d3:0000:8a2e:0070:7344", // 2001:0db8:0000:08d3:0000:8a2e:XXXX:XXXX "207.142.131.5", // 207.142.XXX.XXX "2001:0db8::8d3::8a2e:7:7344", // 2001:0db8::8d3::8a2e:XXXX:XXXX "::1", // :XXXX:XXXX "127.0.0.1" // 127.0.XXX.XXX ]; $tests=preg_replace(['/\.\d*$/','/\d*:\d*$/'],['.XXX','XXXX:XXXX'],$tests); var_export($tests);
based on 4nCg7
Output for 5.6.0 - 5.6.30, hhvm-3.18.5 - 3.22.0, 7.0.0 - 7.3.0beta1
array ( 0 => '207.142.131.XXX', 1 => '2001:0db8:0000:08d3:0000:8a2e:XXXX:XXXX', 2 => '207.142.131.XXX', 3 => '2001:0db8::8d3::8a2e:XXXX:XXXX', 4 => ':XXXX:XXXX', 5 => '127.0.0.XXX', )