Regex Replace
Rewrite text with a regex pattern and a replacement template that can reuse the captured pieces.
Processed locally in your browser/ Your data stays in your browser.
What is Regex Replace?
Regex Replace substitutes every match of a pattern with a replacement string. Unlike a plain find-and-replace, the replacement can reuse what was captured: $1 and $2 insert numbered groups, $<name> inserts a named group, $& the whole match, $` and $' the text before and after it, and $$ a literal dollar sign.
It is built for reformatting: swapping "Last, First" into "First Last", converting dates, wrapping numbers, stripping tags or normalizing separators. A table lists the first 100 replacements (position, original and new text) so you can check the effect, and the replacement count is shown. The pattern runs in a worker with a 5-second limit and is limited to 2,000 characters.
How does it work?
- Enter the pattern and the flags (g replaces all matches, gm makes ^ and $ work on each line).
- Write the replacement using $1, $2, $<name> or $&. \n and \t insert a line break and a tab.
- Paste the text, check the preview table and the count, then copy the result.
Common use cases
- Reordering names, dates or codes with capture groups (2024-01-15 → 15/01/2024).
- Adding quotes, brackets or prefixes around every number or word.
- Removing HTML-like tags, comments or trailing whitespace across many lines.
- Refactoring identifiers in pasted code with a systematic pattern.
Examples
Try this input in the tool above:
John Smith Jane Doe Ada Lovelace
Privacy
Regex Replace runs entirely in your browser. The text or files you provide are processed on your device and are not uploaded, logged or stored on our servers.
Limitations
Only JavaScript syntax and replacement templates are supported. Without the g flag only the first match is replaced.
Frequently asked questions
How do I keep a dollar sign in the replacement?
Write $$. A single $ followed by something that is not a group reference is kept as is.
How does this differ from Find and Replace?
Find and Replace is a general text tool with plain-text mode and match-case options. Regex Replace is regex-only, exposes every flag, and shows each replacement in a table.
What does an empty match do?
A pattern that can match nothing, such as x*, matches between every character, so the replacement is inserted at each position.
Related tools
Regex Tester
Write a pattern, paste some text and see every match highlighted, with its position and capture groups.
Developer Tools
Find and Replace
Search a block of text and replace every occurrence, as plain text or with a regular expression and capture groups.
Text Tools
Regex Match Extractor
Pull every piece of text that matches a pattern out of a long document and get it as a tidy list.
Developer Tools
Regex Escape
Turn any literal text into a safe regex pattern by escaping the characters that have a special meaning, or reverse it.
Developer Tools
Remove Extra Spaces
Clean up spacing in pasted text: double spaces, stray tabs, trailing spaces and runs of blank lines.
Text Tools
Case Converter
One tool for every text case: pick a style from the list and the text is converted instantly.
Text Tools