3v4l.org

run code in 200+ php & hhvm versions
Bugs & Features
<?php function replace($url){ $url = str_replace("\\r","\r",$url); $url = str_replace("\\n","\n<BR>",$url); $url = str_replace("\\n\\r","\n\r",$url); $in=array( '`(?:https?|ftp)://\S+[[:alnum:]]/?(?<!\.(png|jpeg|jpg|gif)\b)`si', '`(?<!//)(www\.\S+[[:alnum:]]/?)(?<!\.(png|jpeg|jpg|gif)\b)`si', //'`(?:https?|ftp)://\S+[[:alnum:]]\.(png|jpeg|jpg|gif)\b`si', //'`(?<!//)(?:www\.\S+[[:alnum:]]\.(png|jpeg|jpg|gif)\b)`si' ); // это для ссылок и фото $out=array( '<a style="color:navy;" href="$0" rel="nofollow">$0</a>', '<a style="color:navy;" href="http://$0" rel=\'nofollow\'>$0</a>', //'<img src="$0" rel="nofollow">', //'<img src="http://$0" rel=\'nofollow\'>' ); return preg_replace($in, $out, $url); } echo replace('dfd dfdf http://site.ru/ ddd fff http://img.com/pic.png text');
Output for 5.2.5 - 7.2.0
Warning: preg_replace(): Compilation failed: lookbehind assertion is not fixed length at offset 59 in /in/PUvoE on line 20
Output for 4.3.11 - 5.2.4
Warning: preg_replace(): Compilation failed: lookbehind assertion is not fixed length at offset 59 in /in/PUvoE on line 20 Warning: preg_replace(): Compilation failed: lookbehind assertion is not fixed length at offset 56 in /in/PUvoE on line 20 dfd dfdf http://site.ru/ ddd fff http://img.com/pic.png text
Output for 4.3.0 - 4.3.10
Warning: Compilation failed: lookbehind assertion is not fixed length at offset 59 in /in/PUvoE on line 20 Warning: Compilation failed: lookbehind assertion is not fixed length at offset 56 in /in/PUvoE on line 20 dfd dfdf http://site.ru/ ddd fff http://img.com/pic.png text