3v4l.org

run code in 200+ php & hhvm versions
Bugs & Features
<?php function isUrl($text) { $regex = array(); $regex["url"] = '/((([A-Za-z]{3,9}:(?:\/\/)?)(?:[-;:&=\+\$,\w]+@)?[A-Za-z0-9.-]+|(?:www.|[-;:&=\+\$,\w]+@)[A-Za-z0-9.-]+)((?:\/[\+~%\/.\w-_]*)?\??(?:[-\+=&;%@.\w_]*)#?(?:[.\!\/\\w]*))?)/i'; $mat = array(); echo $regex["url"]; preg_match($regex["url"], $text, $mat); var_dump($mat); if ($mat[0]) { echo $mat[0]; } } isUrl("来戳这里!http://aaa.bb.cc sdfsafsdhttp://aa.bb.com");
based on WRBWl
Output for 7.3.0alpha1 - 7.3.0rc6
/((([A-Za-z]{3,9}:(?:\/\/)?)(?:[-;:&=\+\$,\w]+@)?[A-Za-z0-9.-]+|(?:www.|[-;:&=\+\$,\w]+@)[A-Za-z0-9.-]+)((?:\/[\+~%\/.\w-_]*)?\??(?:[-\+=&;%@.\w_]*)#?(?:[.\!\/\w]*))?)/i Warning: preg_match(): Compilation failed: invalid range in character class at offset 119 in /in/rfoor on line 7 array(0) { } Notice: Undefined offset: 0 in /in/rfoor on line 9
Output for 4.3.0 - 7.2.6
/((([A-Za-z]{3,9}:(?:\/\/)?)(?:[-;:&=\+\$,\w]+@)?[A-Za-z0-9.-]+|(?:www.|[-;:&=\+\$,\w]+@)[A-Za-z0-9.-]+)((?:\/[\+~%\/.\w-_]*)?\??(?:[-\+=&;%@.\w_]*)#?(?:[.\!\/\w]*))?)/iarray(5) { [0]=> string(16) "http://aaa.bb.cc" [1]=> string(16) "http://aaa.bb.cc" [2]=> string(16) "http://aaa.bb.cc" [3]=> string(7) "http://" [4]=> string(0) "" } http://aaa.bb.cc