Regex find and replace
Replace or extract text with a JavaScript regular expression. Runs in an isolated worker with a hard time limit.
Process locally
Files stay in this browser session. Closing or clearing releases them.
Add text
Type or paste the text to process
Adjust settings
Optional: Pattern, Mode, Replacement and more
Run
Processes in this browser; cancel at any time
About this tool
Find and replace text with a regular expression, or pull out every match. Use it to collapse extra spaces, reformat dates, mask phone numbers, or collect all email addresses or order numbers from a log.
Patterns use JavaScript syntax with optional ignore-case, multiline and dot-all flags, and replacements can insert capture groups with $1. Matching runs in a separate worker that is stopped after 10 seconds, so a runaway pattern cannot freeze the page, and more than 10,000 matches end the run with an error. Your text stays in the browser and is not uploaded.
How to use it
- Paste your text, or select Use example.
- Enter the “Pattern” without surrounding slashes, and choose a “Mode”: “Replace every match” or “Extract matches”.
- When replacing, fill in “Replacement”. Tick “Ignore case”, “^ and $ match each line” or “. matches line breaks” if needed.
- Select Run, then preview and download the text result (replaced.txt or matches.txt) and matches.json.
Formats and limits
- Input
- Text
- Output
- Plain text, JSON
- Size limit
- 1 MB
- Settings
- Pattern; Mode (Replace every match, Extract matches); Replacement; Ignore case; ^ and $ match each line; . matches line breaks
- Privacy
- Files stay in the current browser session. No file bytes are uploaded.
- Price
- Free, no sign-up
Common questions
Which regex syntax and flags are supported?
The pattern is a JavaScript regular expression typed without slashes or flags; the g flag is always on, and the three checkboxes add i, m and s. The u flag is not set, so \p{…} property escapes do not work; use a range such as [\u4e00-\u9fa5] to match common Chinese characters.
How do I use capture groups in the replacement?
Write $1, $2 and so on for numbered groups, $<name> for a named group (?<name>…), and $& for the whole match; type $$ for a literal dollar sign. For example, the pattern (\d{4})-(\d{2})-(\d{2}) with the replacement $3/$2/$1 turns 2026-10-17 into 17/10/2026.
Can I replace matches with a line break?
Not here. “Replacement” is a single-line field, and escapes such as \n are inserted as the two characters \ and n.
In extract mode, how do I get only the capture groups?
The text result, matches.txt, lists each whole match on its own line. The groups of every match, including named groups, are in matches.json together with the position of each match.
Why does my run stop with an error?
A syntax error in the pattern is reported before any matching starts. A run also stops if it takes longer than 10 seconds, which usually means catastrophic backtracking from nested quantifiers such as (a+)+, or if there are more than 10,000 matches, in either mode.
Workflows that use this tool
Related tools
Text beautifier
Add a space between Chinese and English or numbers, optionally switch to Chinese punctuation and tidy paragraphs and spaces.
Letter case and naming styles
Change letter case line by line, or turn phrases and identifiers into camelCase, PascalCase, snake_case, kebab-case or CONSTANT_CASE.
Compare text
Compare two texts line by line with line numbers, and download a unified diff and a JSON report.
Line tools: trim, dedupe, sort
In one pass: trim lines, remove empty or duplicate lines, count repeats, filter by length, sort (including natural and pinyin order) and add a prefix or suffix.
Chinese to pinyin
Convert Chinese to pinyin with tone marks, tone numbers or no tones, reading polyphonic characters from context; or give first letters or characters annotated with pinyin.
Punctuation converter
Turn all punctuation into Chinese full-width or English half-width marks; numbers, times and links keep theirs.