以下函數將替換英文方式下的單引號和雙引號,當然change函數編寫決定了你要替換什么?
String.prototype.repSpecChar=function()
{
filterChar="'|\"";//需要過濾的字符
//var reg=new RegExp("(')|(\")","g");
var reg=new RegExp(filterChar,"gm");
var newstr= this.replace(reg,change);
return newstr;
}
function change(word)
{
if(word=="'") return "'";
if(word=="\"") return """;
}
浙公網安備 33010602011771號