Rifts Posted December 13, 2010 Share Posted December 13, 2010 Hey guys I need to use preg match for this: I have a paragraph saved to a $var I need to run preg match on the $var and make anything that is http:// into a link so I'm guessing that would require replacing http:// with <a href="that link somehow">the original link and then also adding </a> at the end somehow? any ideas? Link to comment https://forums.phpfreaks.com/topic/221552-im-terrible-with-preg_match/ Share on other sites More sharing options...
Rifts Posted December 13, 2010 Author Share Posted December 13, 2010 Ok I found out how to do it but I need help updating this $str2 = ereg_replace("[[:alpha:]]+://[^<>[:space:]]+[[:alnum:]/]","<a href=\"\\0\">\\0</a>", $str1); Link to comment https://forums.phpfreaks.com/topic/221552-im-terrible-with-preg_match/#findComment-1146861 Share on other sites More sharing options...
Rifts Posted December 13, 2010 Author Share Posted December 13, 2010 $str2 = preg_replace("/(http:\/\/[^\s]+)/", "<a href=\"$1\">$1</a>", $str1); Link to comment https://forums.phpfreaks.com/topic/221552-im-terrible-with-preg_match/#findComment-1146875 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.