Applies a regex replacement to the given text, skipping string literals and comments.
Prevents accidental renaming of identifiers that appear inside strings or comments.
Parameters
text: string
The text to apply the replacement to.
pattern: RegExp
The pattern to match. Must have the global flag set.
Applies a regex replacement to the given text, skipping string literals and comments. Prevents accidental renaming of identifiers that appear inside strings or comments.