Currently I use this:
function parseFormat(text) {
text = text.replace(/[\_]{2}([^\_]+)[\_]{2}/g, '<u>$1</u>');
text = text.replace(/[\*\_]{2}([^\*\_]+)[\*\_]{2}/g, '<b>$1</b>');
text = text.replace(/[\*\_]{1}([^\*\_]+)[\*\_]{1}/g, '<i>$1</i>');
text = text.replace(/[\~]{2}([^\~]+)[\~]{2}/g, '<del>$1</del>');
return text;
}
And to parse: agent_messages.forEach(e => e.innerHTML = parseFormat(e.innerHTML));
And I wish to use other kind of combinations for above.
Like:
!@#
for bold$%^
for underline&*(
for italic)_+
for strikethrough
So for bold it should be : !@# bold !@# (= bold)
Can anyone help with this code? It's quite complex.