8
Lately I have used some systems that have the following function, when writing a text between **
it turns this text into bold for example:
Julio *Enrique* dos Santos
expected result will be:
Julio Henrique dos Santos
I thought about creating something similar using javascript and html, but I found 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 couldn’t get out of there. He changes the first *
by a <b>
, but does not close it and has to be something flexible to do whenever it occurs in string. Is there any way? I thought about REGEX, but I don’t know if it would be possible.
Related answer: https://answall.com/a/98376/5878
– Woss
Would be only 1 bold or could occur more than 1?
– Sam
Opa Sam! would be more often, this at the end of the question :)
– Julio Henrique