Sometimes when replacing a string with JS, replyText= replyText.replace("aa","");
This can only replace the first aa in the string. Sometimes it is necessary to replace all aa. This method cannot be used. .
You can use the following method for reference:
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
reallyDo is who to replace
replaceWith is what to replace with.
var replyText="
Respectfully, respectfully, respectfully, respectfully, respectfully
Respectfully, respectfully Respectfully, respectfully, respectfully, respectfully
";
eg:
replyText= del_html_tags(replyText,"
"," ");
replyText= del_html_tags(replyText,"
","");
replyText= del_html_tags(replyText,"
","");
You can get
"Respectfully, respectfully, respectfully, respectfully, respectfully, respectfully, respectfully, respectfully, respectfully, respectfully, respectfully, respectfully, respectfully, respectfully, respectfully, respectfully, respectfully, respectfully, respectfully, respectfully, respectfully, respectfully, respectfully, respectfully, respectfully, respectfully, respectfully, respectfully, respectfully, and respectfully"