As shown below:
function toTxt(str) { var RexStr = /\<|\>|\"|\'|\&/g str = str.replace(RexStr, function(MatchStr) { switch (MatchStr) { case "<": return "<"; break; case ">": return ">"; break; case "\"": return """; break; case "'": return "'"; break; case "&": return "&"; break; default: break; } }) return str; }
The above article uses JS regular expressions to replace brackets, angle brackets, etc. This is all the content shared by the editor. I hope it can give you a For reference, I also hope that everyone will support the PHP Chinese website.
For more related articles on using JS regular expressions to replace brackets, angle brackets and other related articles, please pay attention to the PHP Chinese website!