function(str) { str = dr.ConvertToString(str); while (/&/.test(str)) { str = str.replace(/&/, "&"); } while (/'/.test(str)) { str = str.replace(/'/, "'"); } while (/"/.test(str)) { str = str.replace(/"/, """); } while (/</.test(str)) { str = str.replace(/</, "<"); } while (/>/.test(str)) { str = str.replace(/>/, ">"); } return str;}
怎么改比較好?這樣寫會(huì)讓人覺(jué)得正則基礎(chǔ)太差.
正則匹配 & ' " < >
慕田峪4524236
2018-12-07 11:55:18