jquery - Replace all content between characters with JavaScript -


I am trying to create a simple markdown converter for getting better at JS and Regex.

I now need to find everything between two asterisks, and they & lt; I & gt; Wrap the tag:

  var html = '* abc wire *'; Var html = html.replace (/ \ * / g, ' gt;'); Console.log (html);   

RESULT:

& lt; I & gt; ABC is a string & lt; I & gt;

I also answer a related question, but I am unsure about how to adjust my code accordingly, or what it really is:

(? S) & lt; H1>. & Lt; / H1>

Any help would be great.

Get content wrapped in HTML tags:

  Var html = html.replace (/ \ * ([^ *] +) \ * / g, ' $ 1 & lt; / i & gt;'); Explanation of  ([^ *] +) :  
  (# Start of Capture group [^ # Start of denial]   

So

then [^ *] + means "at least one letter that matches the * is not. It has the effect that all the characters from next to * are matched.

Comments

Popular posts from this blog

Verilog Error: output or inout port "Q" must be connected to a structural net expression -

jasper reports - How to center align barcode using jasperreports and barcode4j -

c# - ASP.NET MVC - Attaching an entity of type 'MODELNAME' failed because another entity of the same type already has the same primary key value -