OK I’m stuck again, this time it’s a problem with the regex… Was searching google, was searching SO, but there wasn’t a post that made me happy… So to make a long story short:
- §text = Database entry string -> could be everything
-
$text gets parsed and the regex should replace everything between 2 * with:
[bla].$matchedtext.[blub]
So I’ve tried to find the right regex for that and that’s what I came up with:
$text= preg_replace('~(/\*([^\"]*?)\*/)~', "$1<b>$2</b>", $text);
And the 2 * per match should disappear as well :/…
Obviously it doesn’t work, elsewhise I wouldn’t post 😀 -> Any ideas?
This should probably do it:
A few comments on your earlier regular expression:
The non-greedy
*is not necessary; when you’re looking at a negative character set, simply add the ‘*’ inside the character set. Also, the double quote doesn’t need escaping.You only need memory groups for things you wish to remember; in your case, you don’t want to know that you matched a beginning and ending asterisk. So you can do your whole matching with just one memory group.