Following is a javascript function using regex to convert HTML BR tags to "\n" new lines.
function replaceHTMLBR(inputMesg) {
var retMesg = inputMesg.replace(/(<br\s*[\/]?>)|(<br\s*[\/]?>)/ig, "\n");
return retMesg;
}
I found this website very useful to check syntax errors of regular expression.
http://regex101.com/#Javascript