Regex Replace
Replace text globally with an ECMAScript regular expression and a supplied replacement string.
How to use
- Enter source text, regex pattern, replacement, and flags, then run.
Capabilities and scope
Pattern, replacement, and flags are separate; flags are limited to gimsuy and g is automatically added when absent.
How it works
The runner constructs new RegExp(pattern, normalizedFlags) and calls input.replace(expression,replacement).
Example
Pattern \s+ with a single-space replacement can collapse runs of whitespace.
Useful for
- Test pattern-based bulk replacement and copy the transformed text
Before you use it
- JavaScript replacement tokens such as $& and $1 are interpreted, and invalid patterns or flags produce an error.
Frequently asked questions
Must I type the g flag?
No. The runner adds g automatically when it is missing.