In direct follow-up to this previous question, how can I pull the text (and the braces if possible) out as a match using PHP?
Specifically, I am writing a Wordpress plugin and am looking to reformat all text between two curly braces (a quasi wiki-marking).
I've followed the steps outlined in another previous question I asked, and have the matching part working - it's the match I need help with.
Example:
This is some {{text}} and I want to reformat the items inside the curly braces
Desired output:
This is some *Text fancified* and I want to reformat the items inside the curly braces
What I have (that is not working):
$content = preg_replace('#\b\{\{`.+`\}\}\b#', "<strong>$0</strong>", $content);
If matching including the braces is too difficult, I can match using the braces as offsets, and then remove the 'offending' braces afterwards, too, using a more simple text-match function.
$content = preg_replace('/{([^{}]*)}/', "<strong>$1</strong>", $content);
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With