Js 正则表达式 RegExp .

详细参考:http://www.w3school.com.cn/js/jsref_obj_regexp.asp

直接量语法

/pattern/attributes

创建 RegExp 对象的语法:

new RegExp(pattern, attributes);

lmth = lmth.replace(new RegExp("\\$" + _d.name + "\\$","g" ),"hello") ;

要用两个 \\ 转义成一个 \ . 如果 _d.name 为 123的话. 写法等同如下:

lmth = lmth.replace(new RegExp(/\$123\$/g),"hello") ;

posted @ 2010-05-14 00:03  NewSea  阅读(1073)  评论(0编辑  收藏  举报