Skip to content Skip to sidebar Skip to footer

Literal Dollar Sign In A Regular Expression

I am working with Canada (fr-CA) locale and trying to do following: var str = '{1}'; var temp = ''; str = str.replac

Solution 1:

$' has a special meaning in the replacement string when using JS regular expressions: it inserts the portion of the string that follows the matched substring. To get a literal dollar sign in the replacement string, use $$.

See https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/replace.

Solution 2:

Could you just use the ascii code for dollar sign? $

Post a Comment for "Literal Dollar Sign In A Regular Expression"