3v4l.org

run code in 300+ PHP versions simultaneously
<?php $regex = '/^http:\/\/([\w.]+)\/([\w]+)\/([\w]+)\.html$/i'; $str = 'http://www.youku.com/show_page/id_ABCDEFG.html'; $matches = array (); if (preg_match ( $regex, $str, $matches )) { var_dump ( $matches ); } echo "\n"; $regex = '#^http://([\w.]+)/([\w]+)/([\w]+)\.html$#i'; $str = 'http://www.youku.com/show_page/id_ABCDEFG.html'; $matches = array (); if (preg_match ( $regex, $str, $matches )) { var_dump ( $matches ); } echo "\n"; $regex = '/^[\d]{5,}$/i'; $str = '324546'; $matches = array (); if (preg_match ( $regex, $str, $matches )) { var_dump ( $matches ); } echo "\n"; if(preg_match("/php/i", "PHP is the web scripting language of choice.", $matches)){ print "A match was found:". $matches[0]; var_dump($matches); } else { print "A match was not found."; } $regex = '/HELLO/'; $str = 'hello word'; $matches = array(); if(preg_match($regex, $str, $matches)){ echo 'No i:Valid Successful!',"\n"; } if(preg_match($regex.'i', $str, $matches)){ echo 'YES i:Valid Successful!',"\n"; } $regex = '/HE(?=L)LO/i'; $str = 'HELLO'; $matches = array(); if(preg_match($regex, $str, $matches)){ var_dump($matches); } echo "\n"; $regex = '/HE(?=L)LLO/i'; $str = 'HELLO'; $matches = array(); if(preg_match($regex, $str, $matches)){ var_dump($matches); } echo "\n"; $regex = '/^(Chuanshanjia)[\w\s]+$/'; $regex2='/^(Chuanshanjia)([\w]|[\s])+$/'; $str = 'Chuanshanjia thank Chuanshanjia'; $matches = array(); if(preg_match($regex2, $str, $matches)){ var_dump($matches); } echo "\n"; ?>
Output for 4.3.0 - 4.3.11, 4.4.0 - 4.4.9, 5.0.0 - 5.0.5, 5.1.0 - 5.1.6, 5.2.0 - 5.2.17, 5.3.0 - 5.3.29, 5.4.0 - 5.4.45, 5.5.0 - 5.5.38, 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.28, 8.2.0 - 8.2.18, 8.3.0 - 8.3.6
array(4) { [0]=> string(46) "http://www.youku.com/show_page/id_ABCDEFG.html" [1]=> string(13) "www.youku.com" [2]=> string(9) "show_page" [3]=> string(10) "id_ABCDEFG" } array(4) { [0]=> string(46) "http://www.youku.com/show_page/id_ABCDEFG.html" [1]=> string(13) "www.youku.com" [2]=> string(9) "show_page" [3]=> string(10) "id_ABCDEFG" } array(1) { [0]=> string(6) "324546" } A match was found:PHParray(1) { [0]=> string(3) "PHP" } YES i:Valid Successful! array(1) { [0]=> string(5) "HELLO" } array(3) { [0]=> string(31) "Chuanshanjia thank Chuanshanjia" [1]=> string(12) "Chuanshanjia" [2]=> string(1) "a" }

preferences:
301.03 ms | 407 KiB | 460 Q