3v4l.org

run code in 300+ PHP versions simultaneously
<?php function testRegExp($regexp, $string) { $valid = preg_match($regexp, $string); echo $string. " - " . ($valid ? "valid" : "invalid") ."\n"; } function matchRegExp($regexp, $text){ if(preg_match($regexp, $text, $matches)){ print_r($matches); }else{ echo "no match in text: ".$text; } echo "\n"; } // hledání emailu @seznam.cz v textu (zjednodušená verze) $regexpEmail = "/\b(?P<email>\w+@seznam\.cz)\b/"; matchRegExp($regexpEmail, "adsd dominik@seznam.cz ssdasd"); matchRegExp($regexpEmail, "adsd dominik@seam.cz ssdasd"); // validace IP adresy $regexpIp = "/^((25[0-5]|2[0-4]\d|[01]?\d?\d)\.){3}(25[0-5]|2[0-4]\d|[01]?\d?\d)$/"; echo "Test IP\n"; testRegExp($regexpIp, "10.1.0.1"); testRegExp($regexpIp, "199.1.0.1"); testRegExp($regexpIp, "255.1.0.1"); testRegExp($regexpIp, "256.1.0.1"); testRegExp($regexpIp, "260.1.0.1"); testRegExp($regexpIp, "300.1.0.1"); testRegExp($regexpIp, "1.0.1"); testRegExp($regexpIp, "125.1..1"); testRegExp($regexpIp, "192.11.168.255"); testRegExp($regexpIp, "192.11.168.256"); testRegExp($regexpIp, "192.11.168.300");
Output for 5.6.0 - 5.6.40, 7.0.0 - 7.0.33, 7.1.0 - 7.1.33, 7.2.0 - 7.2.33, 7.3.0 - 7.3.33, 7.4.0 - 7.4.33, 8.0.0 - 8.0.30, 8.1.0 - 8.1.27, 8.2.0 - 8.2.17, 8.3.0 - 8.3.4
Array ( [0] => dominik@seznam.cz [email] => dominik@seznam.cz [1] => dominik@seznam.cz ) no match in text: adsd dominik@seam.cz ssdasd Test IP 10.1.0.1 - valid 199.1.0.1 - valid 255.1.0.1 - valid 256.1.0.1 - invalid 260.1.0.1 - invalid 300.1.0.1 - invalid 1.0.1 - invalid 125.1..1 - invalid 192.11.168.255 - valid 192.11.168.256 - invalid 192.11.168.300 - invalid

preferences:
261.89 ms | 404 KiB | 287 Q