Jump to content

How to i replace </p> without error


wilsonf1

Recommended Posts

when i attempt to replace all my closing P tags like this:vText = vText.replace(/</p>/g, "\n\n");i get: invalid flag after regular expression[break on this error] vText = vText.replace(/</p>/g, "\n\n");\nfair enough - but how do i get round it???????out of interest i am converting word format text in a textarea to valid paragraph thml, theb back again - the first conver works great with this:vText = vText.replace(/\n\n/g, "</p>\n<p>");vText = "<p>" + vText + "</p>but trying to get it back into normal text is tricky with that error!!!

Link to comment
Share on other sites

vText.replace(/<\/p>/g, "\n\n");The forward slash in front of "p" looks like the end of the regular expression, and the replace method doesn't understand the characters that follow. So add the escape character in front of it.

Link to comment
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...