Forum Moderators: open
html = html.replace("<p> </p>","<br />"); (where 'html' is my string)
and this:
html = html.replace(/<p> <\/p>/g,"<br />"); and this:
html = html.replace(/<p> <\/p>/g,"<br \/>"); with no luck... what am I doing wrong?
BTW: I know html/php... but little Javascript...
Thanks,
-Jason
var test = "Here is <p> </p> a test <p> </p> string";
alert( test.replace(/<p> <\/p>/g,"<br />") ); If this is HTML from innerHTML it might be good to ignore case, and allow for unexpected whitepace.
alert( test.replace(/<p>\s* \s*<\/p>/gi,"<br />") );