I have an array with regular expressions that I use to replace url's / hashtags on links using preg_replace
:
$regs = array('!(\s|^)((https?://|www\.)+[a-z0-9_./?=;&#-]+)!i', '/#(\w+)/');
$subs = array(' <a href="$2" target="_blank">$2</a>', '<a href="/hashtag/$1" title="#$1">#$1</a>');
$saida = preg_replace($regs, $subs, $conteudo);
If $conteudo
has a link, for example: link , it replaces correctly; if you have a forg followed by text, for example #boatarde it also replaces, however, if you have a link that has a hashtag, for example: link the replacement is as follows:
#topo "target=" _ blank "> link #topo
and only bold parts turn into links.
How to fix?