PHP preg_replace to include ** xyz ** in <b> xyz </b>
I decided, for fun, to do something like markdowns. Thanks to my little experience with regular expressions in the past, I know how strong they are, so they will be what I need.
So, if I have this line:
Hello **bold** world How can I use preg_replace to convert it to:
Hello <b>bold</b> world Am I guessing something like this?
$input = "Hello **bold** world"; $output = preg_replace("/(\*\*).*?(\*\*/)", "<b></b>", $input); +4
4 answers