Sometimes when replacing strings with JS, replyText= replyText.replace("aa","");
In this way, you can only replace the first aa in the string. Sometimes you need to replace all aa, and this method cannot be used. .
You can use the following methods as reference:
The code copy is as follows:
function del_html_tags(str,reallyDo,replaceWith) {
var e=new RegExp(reallyDo,"g");
words = str.replace(e, replaceWith);
return words;
}
str is the target string
Who is reallyDo to replace
What is replaceWith replaced?
var replyText="<p>Respectful and respectful</p><p><br /></p><p>Respectful and respectful</p><p><br /></p><p>Respectful and respectful</p><p><br /></p>";
eg:
The code copy is as follows:
replyText= del_html_tags(replyText,"<br />"," ");
replyText= del_html_tags(replyText,"<p>","");
replyText= del_html_tags(replyText,"</p>","");
You can get it
"Respectful and respectful and respectful and respectful"