fork download
  1. <?php
  2.  
  3. echo preg_replace('#(?<!\*)\*([a-zA-Z\s\.]+)\*(?!\*)#i', '<em>$1</em>', '**bold text with *italic* **');
  4.  
  5. echo '<br>';
  6. echo '<br>';
  7.  
  8. echo preg_replace('#(?<!\*)\*([a-zA-Z\s\.]+)\*?(?!\*)#i', '<em>$1</em>', '*italic text **with bold** *');
Success #stdin #stdout 0.01s 82944KB
stdin
Standard input is empty
stdout
**bold text with <em>italic</em> **<br><br><em>italic text</em> **with bold** *