Skip to content
CodeWiki
Practice
Paths
Tracks
Cheatsheets
Playground
Glossary
AI era
Search
⌘K
English
English
Chinese
Practice
Paths
Tracks
Cheatsheets
Playground
Glossary
AI era
English
English
Chinese
Practice
/
Quiz
/
CS foundations
/
Regular expressions
Why is a replacement callback safer when untrusted replacement text may contain dollar si…
from Regular expressions
Node 24
intermediate
4 min
Why is a replacement callback safer when untrusted replacement text may contain dollar signs?
The callback returns literal text instead of letting the replacement-template mini-language interpret `$&`, `$1`, or `$<name>`.
The callback automatically makes the regex linear time.
The callback changes UTF-16 indices into byte offsets.
The callback validates every captured value semantically.
Check
Ask AI about this kata
Report an error
previous kata
What does this global search print?
Predict the output
next kata
Review a generated ticket scanner
Review AI code
A new version is available
Reload