zno2

js replace

some.txt

\ / : * ? " < > |

 

js escape 方法:

该方法不会对 ASCII 字母和数字进行编码,也不会对下面这些 ASCII 标点符号进行编码: *@ - _ + . / 。其他所有的字符都会被转义序列替换。
html 转义符:

@ &#64; --- Commercial at

- &#45; --- 连字号Hyphen

_ &#95; --- 下划线Horizontal bar (underscore)

+ &#43; --- 加号Plus sign

. &#46; --- 句号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;  

更多正则见

http://www.iteye.com/topic/481228

posted on 2016-08-05 18:48  zno2  阅读(123)  评论(0编辑  收藏  举报

导航