3v4l.org

run code in 150+ php & hhvm versions
Bugs & Features
<?php $text = "demo link edno www.abv.bg link 2 http://abv123.bg/"; $reg_exUrl = "/((http|https|ftp|ftps)\:\/\/|(www)\.)[a-zA-Z0-9\-\.]+\.[a-zA-Z]{2,3}(\/\S*)?/"; if(preg_match($reg_exUrl, $text, $url)) { $text = preg_replace($reg_exUrl, '<a href="'.$url[0].'" target="_blank">'.$url[0].'</a> ', $text); } echo $text;
Output for 4.3.0 - 5.6.28, hhvm-3.10.0 - 3.12.0, 7.0.0 - 7.1.0
demo link edno <a href="www.abv.bg" target="_blank">www.abv.bg</a> link 2 <a href="www.abv.bg" target="_blank">www.abv.bg</a>