且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

Javascript正则表达式对象和美元符号

更新时间:2023-02-22 13:53:18

在构建字符串时,RegExp表达式构建器中的\被视为转义字符,就像在实际的RegExp中一样。您需要转义两次,尝试:

The "\" in the RegExp expression builder is treated as an escape character when building the string, just as it is in the actual RegExp. You need to escape twice, try:

new RegExp('\\$'+placeholdername+'\\$');