javascript 的 replace 函数

Code

这是用来做sql 转义字符转换的。刚开始发现只转换了第一个而已。 当时就郁闷了。 用最笨的方法我做两个循环来替换其他的。

后面才发现只要改为: string str1=content.Replace/&/g,"&"); 就可以替换全部了。

public string EnCode(string content)
{
   
string str1=content.replace(/</g,"&lt;");
   
string str2=str1.replace(/>/g,"&gt;");
}

作者:Novus
出处:http://www.cnblogs.com/novus/
本文版权归作者和博客园共有,欢迎任何形式的转载,但请务必注明出处。

原文地址:https://www.cnblogs.com/novus/p/1525310.html