JavaScript: Regex Replacement String Dollar Sign Sequence

By Xah Lee. Date: .

When using regex, the following dollar sign sequence have special meaning in the replace string.

This is used by:

nth captured match. (n is a positive integer less than 100)
refers to named capture name.
the matched string.
the string before the matched string.
the string after the matched string.
literal dollar sign character.

JavaScript Regular Expression

JavaScript in Depth