Answer the question
In order to leave comments, you need to log in
How to add a condition to the regular expression "Is there any characters before the match"?
You need to make a regular expression that replaces hashtags with links.
Here is the code that does it:
$pattern = "/\#(\w+)/ui";
$text = preg_replace($pattern, '<a href="'.site_url().'?s=%23$1&bp_search=1&view=content" target="_blank">#$1</a>',$text);
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question