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

相关文章:

  • 2022-12-23
  • 2022-12-23
  • 2021-12-19
  • 2021-11-23
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
猜你喜欢
  • 2021-10-10
  • 2022-12-23
  • 2022-01-11
  • 2022-12-23
  • 2021-06-03
  • 2022-12-23
  • 2022-12-23
相关资源
相似解决方案