如何替换HTML< br>换行符“\\\
”
问题描述:
我如何取代HTML < BR> < BR />或
换行符\ n
How can I replace HTML <BR> <BR/> or <BR />
with new line character "\n"
答
重新寻找一个等价的PHP br2nl()
。这应该做的工作:
You're looking for an equivilent of PHP's br2nl()
. This should do the job:
function br2nl(str) {
return str.replace(/<br\s*\/?>/mg,"\n");
}