Standardise wording
Replace an old name throughout a list or a document before publishing it.
Replace a text fragment in a pasted or imported document.
Enter the source text, search and replacement. Enable regex only for a JavaScript pattern, then run the replacement.
Correcting a name in a list, removing a marker or rearranging fields can require more than a simple editor replacement. This page accepts pasted or imported text and produces a new version to review, copy or download. Literal mode suits a specific string; JavaScript regular expressions describe a family of matches. The original file is not changed.
Literal mode replaces every occurrence of the search string. Punctuation is ordinary text: a dot searches for a dot, and $1 inserts the two characters dollar and 1. Matching is case-sensitive by default. Ignore case also finds different capitalisations, using the same replacement text for each.
In regex mode, enter the pattern without surrounding slashes: use \bcat\b, not /\bcat\b/g. Flags have a separate field. g processes all matches; without it only the first is replaced. i ignores case. m changes the behaviour of ^ and $ anchors, s lets the dot match line breaks, and u enables Unicode mode.
Parentheses capture part of a match: $1 inserts the first group, $2 the second and $& the whole match. In regex mode, $$ inserts a literal dollar sign. An empty search is rejected; an empty replacement deletes matches. The counter shows how many replacements occurred, helping you spot searches that are too broad or find nothing.
Processing stays local. Editing an input clears the previous result to prevent copying stale output. Regex patterns run in a Worker stopped after two seconds, so an expensive pattern may be interrupted. No partial result is offered in that case; simplify the pattern or start with an excerpt.
Paste or import your text and enter the search string. Punctuation has no special meaning in literal mode.
Enter new text or leave it blank to delete matches. In regex mode, check captures and flags.
Run replacement, review the output, then copy or download it. Editing an input clears the previous result.
Replace an old name throughout a list or a document before publishing it.
Use captured groups to rearrange matching fragments without typing their contents again.
Leave the replacement empty to delete occurrences that match the search.
The search finds all three capitalisations, but the replacement keeps exactly the case you entered: Lyon. Without Ignore case, only the first occurrence would change and the other two would remain untouched.
Input
Text: Paris, PARIS, paris
Search: Paris
Replacement: Lyon
Mode: literal
Ignore case: yesResult
Lyon, Lyon, Lyon
3 replacementsThe first group captures the surname and the second the given name. $2 $1 reverses their positions. This teaching pattern covers ASCII letters only; adapt it for accented names, compound names or apostrophes.
Input
Text: Martin, Alice; Durand, Paul
Pattern: ([A-Za-z]+), ([A-Za-z]+)
Replacement: $2 $1
Mode: regex; flags: gResult
Alice Martin; Paul Durand
2 replacementsA literal search for cat would also replace the start of catfish, producing dogfish with three replacements. The \b boundaries suit this example; they do not provide linguistic segmentation for every Unicode word.
Input
Text: cat, catfish, cat
Pattern: \bcat\b
Replacement: dog
Mode: regex; flags: gResult
dog, catfish, dog
2 replacementsIn literal mode, enter $. In regex mode, $$ inserts a literal dollar sign. Check captures and word boundaries on a small sample before changing a long document.
By default, yes. In literal mode, tick “Ignore case”; in regex mode, add the i flag.
The existing text.replace operation performs literal replacement. Regex on this page runs in its time-limited Worker.
Enable regex and remove the g flag. Other flags remain available: i ignores case, m changes line anchors, s lets the dot match line breaks and u enables Unicode mode.
Related tools
Tools similar or complementary to this one.
Test a regular expression against text and inspect the matches it returns.
Remove extra spaces, repeated tabs and empty lines from copied text.
Convert text to lowercase, UPPERCASE, Title Case or other common case styles.