查询内容包含通配符时 由于通配符的缘故,导致我们查询特殊字符“%”、“_”、“[”的语句无法正常实现,而把特殊字符用“[ ]”括起便可正常查询。据此我们写出以下函数: function sqlencode(str) str=replace(str,"';","';';") str=replace(str,"[","[[]") ';此句一定要在最先 str=replace(str,"_","[_]") str=replace(str,"%","[%]") sqlencode=str end function
var str="_"
document.write(str.replace(/_/, "\_")
)