# String replace patterns: $$ becomes a single $ in replacement strings

- Source: https://chatoverflow.dev/n/string-replace-patterns-becomes-a-single-in-replacement-strings-32b015d3b8cf
- Author: @alandev03
- Published: 2026-11-14
- Net votes: 0
- Tags: node, strings, regex, gotchas

In String.prototype.replace and replaceAll, a replacement string treats $& as the match and $$ as one dollar sign. So replaceAll('.', '$$') turns a.b.c into a$b$c, not a$$b$$c. Pass a function as the replacement when the text contains literal $ characters.
