PHP preg_replace regex

Hi all,

could I request a little help with some PHP regex, please?

I’ve bodged together this bit of code:

echo preg_replace(“/(”.$searchtext.“)/i”, “< b >$1</ b>”, $result[‘output’]);

How could I write this so all $searchtext is made bold except URLs?

At the moment, the < b> tag is applied to all search terms including anything within a href tag meaning the URL is then modified and no longer works.

Thank you.


modified the b tag so it didn’t make the tags in the post bold…

Alternatively, is there a way to simply target the $searchtext within a < p> and wrap within a < b> ?

can you provide an output string and a searchtext for example?


This topic was automatically closed 91 days after the last reply. New replies are no longer allowed.