js replace
some.txt
\ / : * ? " < > |
js escape 方法:
该方法不会对 ASCII 字母和数字进行编码,也不会对下面这些 ASCII 标点符号进行编码: *@ - _ + . / 。其他所有的字符都会被转义序列替换。
html 转义符:
@ @ --- Commercial at
- - --- 连字号Hyphen
_ _ --- 下划线Horizontal bar (underscore)
+ + --- 加号Plus sign
. . --- 句号Period (fullstop)
var s_full = "#*@-_+."; alert(escape(s_full)); // %23*@-_+.
var s_full ="1@3@5@"; var s_sub=s_full.replace(/\@/,"at"); alert(s_sub);//1at3@5@
var s_full ="1@3@5@"; var s_sub=s_full.replace(/\@/g,"at"); alert(s_sub);//1at3at5at
// g 全局搜索 ,i 不区分大小写 // var rule = new RegExp("here","gi"); var rule = /here/gi;
更多正则见