I am trying to convert square brackets in a submit form. I will not go into the form submission part as this is not required.
I had no problem replacing the newline with the <br /> tag as follows:
new_line = message.replace(/\n/g, "<br />");
however, what I'm trying to achieve now converts [b] [/b] to <strong> </strong> . This is what I have tried so far, but it does not seem to work. I find regex is pretty hard to understand.
bold = message.replace(/\[b].*\[\/b]/g, '<strong>');
Can anyone point me in the right direction?
source share