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"; ?>

preferences:
42.92 ms | 402 KiB | 5 Q