Reputation: 499
I want to trim ** from text. If content include **text**
- than is bold
$find = array('/\*\*(.*)\*\*/', '/@(\\w+)/');
$replace = array('<span style="font-weight:bold">$0</span>', '<a href=/profile/$1>@$1</a>');
$result = preg_replace($find, $replace, $content);
but now it looks like: ** bold **
Upvotes: 0
Views: 41
Reputation: 91430
Replace $0
by $1
in your replace array:
$replace = array('<span style="font-weight:bold">$1</span>', '<a href=/profile/$1>@$1</a>');
// here __^^
You'd better use the following instead of a greedy match:
$find = array('/\*\*([^*]+)\*\*/', '/@(\\w+)/');
Upvotes: 1