3v4l.org

run code in 150+ php & hhvm versions
Bugs & Features
<?php $str="Link type 1 - www.google.com <br>link type 2 - http://www.goe3ogLEe.com <br>link type 3 - https://www.google.com <br>link type 4 - http://google.com <br>Link type 5 - http://www.vistaprint.com/local-search-profile.aspx?txi=15664&xnid=TopNav_Local+Search+Profile+ %28linked+item%29_Websites&xnav=TopNav <br>Link type 6 - http://drive.google.com/?tab=mo&authuser=0#folders/0B7ZWeOAbtjQ1OHR1Yf343f33N2M "; $pattern = '#(www\.|https?://)?[\w\d]+\.[\d\w]{2}\S*#i'; $str1=preg_replace($pattern, '<a href="$0">$0</a>', $str); $str1=str_replace('href="www','href="http://www',$str1); echo $str1;
Output for 4.3.0 - 5.6.28, hhvm-3.12.0, 7.0.0 - 7.1.0
Link type 1 - <a href="http://www.google.com">www.google.com</a> <br>link type 2 - <a href="http://www.goe3ogLEe.com">http://www.goe3ogLEe.com</a> <br>link type 3 - <a href="https://www.google.com">https://www.google.com</a> <br>link type 4 - <a href="http://google.com">http://google.com</a> <br>Link type 5 - <a href="http://www.vistaprint.com/local-search-profile.aspx?txi=15664&xnid=TopNav_Local+Search+Profile+">http://www.vistaprint.com/local-search-profile.aspx?txi=15664&xnid=TopNav_Local+Search+Profile+</a> %28linked+item%29_Websites&xnav=TopNav <br>Link type 6 - <a href="http://drive.google.com/?tab=mo&authuser=0#folders/0B7ZWeOAbtjQ1OHR1Yf343f33N2M">http://drive.google.com/?tab=mo&authuser=0#folders/0B7ZWeOAbtjQ1OHR1Yf343f33N2M</a>
Output for hhvm-3.10.0

Process exited with code 153.