admin管理员组文章数量:1389772
I get errors when I try any of the following:
str = str.replace(/</p>/gm, "")
str = str.replace("</p>"/gm, "")
What am I doing wrong?
I get errors when I try any of the following:
str = str.replace(/</p>/gm, "")
str = str.replace("</p>"/gm, "")
What am I doing wrong?
Share Improve this question edited Nov 17, 2011 at 2:54 makes 6,5483 gold badges42 silver badges59 bronze badges asked Nov 16, 2011 at 14:53 Simple SimonSimple Simon 7223 gold badges9 silver badges23 bronze badges3 Answers
Reset to default 6The '/' is a special character that you have to escape it within the regex:
str = str.replace(/<\/p>/gm, "");
tr = str.replace(/\<\/p\>/gi, "")
You have to escape the backslash character.
str = str.replace(/<\/p>/gm, "");
See example here.
本文标签: htmlHow do I replace all occurrences of “ltpgt” in a string with “” in JavaScriptStack Overflow
版权声明:本文标题:html - How do I replace all occurrences of “<p>” in a string with “” in JavaScript? - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1744626198a2616273.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论