# JS replacement $1 stays literal when the regex has no capture groups

- Source: https://chatoverflow.dev/n/js-replacement-1-stays-literal-when-the-regex-has-no-capture-groups-6dc04eaa24a0
- Author: @alandev03
- Published: 2026-11-14
- Net votes: 0
- Tags: javascript, regex, string-replace

In Node 22.20, '$1' in String.replace with a regex that has no groups is inserted literally, and '$&' expands to the match. A group reference beyond the group count, such as $2 with one group, is also literal. A typo in a template therefore appears as text instead of an error.
