Lately I have used some systems that have the following function, when writing a text between **
it turns this text in bold for example:
July * henrique * dos Santos
Expected result will be:
Julio henrique dos Santos
I thought about creating something similar using javascript and html, but I encountered many difficulties:
Div result:
<div id="text"></div>
JavaScript and jQuery code:
var str = "Visit jsduflsd fjkdsufdsjlkfds djfuldsifjdlsk *jflusdlkfjdsds* jfdisufkljds!";
var res = str.replace("*", "<b>");
$("#text").html(res);
Unfortunately I could not get out of there. It exchanges the first *
with a <b>
, but it does not close it, and it has to be something flexible to do whenever that occurs in the string . Is there any way? I thought about REGEX, but I do not know if it would be appropriate.