且构网

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

使用美元符号($)作为替换时,`string.replace`奇怪的行为

更新时间:2023-02-18 09:14:52

为了在结果字符串中使用 $ ,请使用 $$ as $ 在JavaScript正则表达式和字符串替换中有特殊含义>方法: https://developer.mozilla.org/en/ JavaScript / Reference / Global_Objects / String / replace#Specifying_a_string_as_a_parameter

In order to use $ in resulting string, use $$ as $ has special meaning in JavaScript Regular Expressions and String replace method: https://developer.mozilla.org/en/JavaScript/Reference/Global_Objects/String/replace#Specifying_a_string_as_a_parameter