I'm using a textarea to write a text like this:
%this is my text %%also text simple text %%%last text
If a paragraph starts with
%, it should show the whole line with
<h1>, if there are 2,
%%, it should be
<h2> and so on until
For the above example it must return:
<h1>this is my text</h1> <h2>also text</h2> simple text <h3>last text</h3>
I've done this:
var result = inputVal.replace('%', '<h1>');
it replaces the symbol at the beginning but I don't know how to add the closing tag at the end of the line. And also how to count how many
% are so it can show , or other ones.
Is the a way to do this?