0

I want to make a PHP function that would make text bold between 1 asterisk, then regular text otherwise.

Example:

Welcome to my store *This is my house* It is located in

Who can help me out? I tried to do this, but not being successful.

        if(preg_match("/[a-zA-Z0-9_]* *\(*\*[a-zA-Z0-9_]*\*\)* *[a-zA-Z0-9_]*/
", $text, $temp))
    {
        $newText = " " . $text . " ";
        $split = spliti("\\*", $newText);
Andreas
  • 23,610
  • 6
  • 30
  • 62
ohdust
  • 11
  • 1
  • 7
  • So?? JavaScript or PHP? – Andreas Jun 16 '19 at 18:57
  • PHP I would prefer. – ohdust Jun 16 '19 at 18:58
  • 1
    Surely there’s a markdown class out there to use. That would be far easier than reinventing the wheel. The problem is it’s not just searching for asterisks. You have to search for pairs so that you can substitute the opening and closing tags. And what happens if you have two italicized phrases in a string? The regex can’t be greedy. – Tim Morton Jun 16 '19 at 19:02
  • Take a look to this solution please, it looks similiar: https://stackoverflow.com/a/19256736/11639309 – Anton Jun 16 '19 at 23:49

0 Answers0