immanuelx2 Posted May 29, 2009 Share Posted May 29, 2009 hey all. I currently have a preg_replace function to highlight search terms with the following: <?php $article_text = preg_replace("/\b(".$_GET['search'].")\b/i", '<span style="background:#ffffab">\1</span>', $article['text']); However, the problem is that if a URL using bbcode (ex. Link) contains the search keyword, it will wrap <span> around it and mess up the link. Is there any way I can add to the regexp where "search term" is NOT between "" ? Thanks in advance Quote Link to comment https://forums.phpfreaks.com/topic/160201-preg_replace-highlight-search-terms-how-to-disregard-urls/ Share on other sites More sharing options...
immanuelx2 Posted May 30, 2009 Author Share Posted May 30, 2009 bump. Again, I am trying to get the search term to not parse inside URLS Any help? Quote Link to comment https://forums.phpfreaks.com/topic/160201-preg_replace-highlight-search-terms-how-to-disregard-urls/#findComment-845754 Share on other sites More sharing options...
Daniel0 Posted May 30, 2009 Share Posted May 30, 2009 Any reason why you can't use what's discussed in this sticky topic? http://www.phpfreaks.com/forums/index.php/topic,122857.0.html Also, do make sure you read the rules. You obviously haven't yet. Quote Link to comment https://forums.phpfreaks.com/topic/160201-preg_replace-highlight-search-terms-how-to-disregard-urls/#findComment-845764 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.