Robert Mark Bram wrote on 27 sep 2004 in comp.lang.javascript
:
I have the following to replace newline chars with <br> in a string:
.replace(/\n/g,"<br>")
How can I change this so that it replaces only if there is not already a
"<br>newline" or "newline<p>" combo?
if(/#$#$#$#/.test(t))alert("error")
t=t.replace(/\n/g,"#$#$#$#")
..replace(/#$#$#$#<p>/g,"\n<p>")
..replace(/<br>#$#$#$#/g,"<br>\n")
..replace(/#$#$#$#/g,"<br>")
// all replaces on one line please !!
not tested
--
Evertjan.
The Netherlands.
(Please change the x'es to dots in my emailaddress,
but let us keep the discussions in the newsgroup)