详细参考: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") ;