龙空技术网

js 特殊字符转化

Jiakly 49

前言:

目前各位老铁们对“js replaceall”大致比较关注,大家都需要剖析一些“js replaceall”的相关文章。那么小编同时在网上汇集了一些对于“js replaceall””的相关文章,希望我们能喜欢,看官们快快来了解一下吧!

//特殊字符转化

function specialSymbolsTransfer(str){

if(str!=null && str!=""){

return str.replaceAll("?","?").replaceAll(",",",").replaceAll(";", ";").replaceAll(":",":").replaceAll("''","'")

.replaceAll("\"",""").replaceAll("[","[").replaceAll("]","]").replaceAll("{","{").replaceAll("}","}").replaceAll("+","+").replaceAll("-","-")

.replaceAll("(", "(").replaceAll(")", ")").replaceAll("*", "*").replaceAll("&", "&").replaceAll("^","^").replaceAll("%","%")

.replaceAll("$","$").replaceAll("#","#").replaceAll("@","@").replaceAll("!","!").replaceAll("<","\"<").replaceAll(">",">");

}

return str;

}

标签: #js replaceall