fork(1) download
  1. // Online Javascript Editor for free
  2. // Write, Edit and Run your Javascript code using JS Online Compiler
  3. let text = `*this text is bold*,
  4. _this text is italic_,
  5. ~this text is strikethrough~.
  6. ~_*this text is bold, italic and strike-through*_~`
  7.  
  8. let html_wrapped_text = text
  9. .replace(/(?:\*)(?:(?!\s))((?:(?!\*|\n).)+)(?:\*)/g, '<b>$1</b>')
  10. .replace(/(?:_)(?:(?!\s))((?:(?!\n|_).)+)(?:_)/g, '<i>$1</i>')
  11. .replace(/(?:~)(?:(?!\s))((?:(?!\n|~).)+)(?:~)/g, '<s>$1</s>');
  12.  
  13. console.log(html_wrapped_text);
Success #stdin #stdout 0.03s 17340KB
stdin
Standard input is empty
stdout
<b>this text is bold</b>, 
<i>this text is italic</i>,
<s>this text is strikethrough</s>.
<s><i><b>this text is bold, italic and strike-through</b></i></s>