kidrobot2008 Posted August 10, 2008 Share Posted August 10, 2008 I need help converting the following working statement so it uses preg_replace instead. $text = "I love PHP Freaks."; $text = ' '. $text .' '; $words = "PHP Freaks"; $link = "<a href=http://www.phpfreaks.com>PHP Freaks</a>"; $text = eregi_replace("([ ,\.\?!:\(\)\r\n\<\>])". preg_quote($words) ."([ ,\.\?!:\(\)\r\n\<\>])", "\\1". ($link) ."\\2", $text); In the real deal $text is a paragraph of text and $words is a name. Thanks in advance. K Link to comment https://forums.phpfreaks.com/topic/119037-convert-working-eregi_replace-to-preg_replace/ Share on other sites More sharing options...
effigy Posted August 11, 2008 Share Posted August 11, 2008 $text = preg_replace('/\b'. preg_quote($words) . '\b/', $link, $text); Link to comment https://forums.phpfreaks.com/topic/119037-convert-working-eregi_replace-to-preg_replace/#findComment-613538 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.