title: Using js regex to replace simple markup styles like **bold** to <b>bold</b>
body: <p>I'm trying to take a chunk of plain text and convert parts of it into html tags. I don't need a full rich editor, just these few tags:</p>
  
  <pre><code>**bold**
  __underline__
  ~~italics~~
  --strike--
  &lt;&lt;http://www.link.com&gt;&gt;
  </code></pre>
  
  <p>This is the method I have attempted to write but my lack of regex/js seems to be holding it back:</p>
  
  <pre><code>function toMarkup($this) {
      var text = $this.text();
      text = text.replace("\*\*(.*)\*\*", "&lt;b&gt;$1&lt;/b&gt;");
      text = text.replace("__(.*)__", "&lt;u&gt;$1&lt;/u&gt;");
      text = text.replace("~~(.*)~~", "&lt;i&gt;$1&lt;/i&gt;");
      text = text.replace("--(.*)--", "&lt;del&gt;$1&lt;/del&gt;");
      text = text.replace("&lt;&lt;(.*)&gt;&gt;", "&lt;a href='$1'&gt;Link&lt;/a&gt;");
      $this.html(text);
  }
  </code></pre>
  
  <p>Any glaring errors as to why these replaces are not working? Another issue I'm just now realizing is by converting this text to html I am unescaping any other potential tags that may be malicious. A bonus would be any advice on how to only escape these elements and nothing else.</p>