Find and Replace Text | Literal and Regex Replacement

TextRuns in Your Browser (No Uploads)

Replace literal text or JavaScript regular-expression matches with explicit Unicode boundaries, capture tokens, multiline and dot-all flags, replacement escapes, exact counts, and a one-second browser Worker deadline.

What to do next

Continue with a related workflow or open the next tool that usually follows this task.

How to Use This Tool

Keep an untouched source copy and identify whether capitalization, boundaries, line endings, and dollar characters are meaningful.

Paste text or select a local text file within the displayed source limits.

Enter a find value and replacement; an empty replacement deletes accepted matches.

Choose Literal text for exact values or Regular expression for patterns, then set case and whole-value rules.

In regex mode, choose multiline, dot-all, and capture expansion explicitly; enable replacement escapes only for the documented sequences.

Run the Worker, inspect candidate, replacement, boundary, and zero-width diagnostics, compare the output, then copy or download it.

When to Use This Tool

Configuration updates

Update environment names, hostnames, paths, or labels while confirming exact replacement counts.

Boundary-aware refactoring

Rename standalone identifiers without changing longer names that merely contain the same substring.

Structured field reformatting

Reorder dates, names, or log fields with numbered or named regex captures.

Controlled separator insertion

Insert line breaks or tabs through an explicit replacement escape policy instead of hidden editor behavior.

Local text sanitization

Replace private names or internal host labels with reviewed placeholders before sharing a minimal example.

Common Mistakes

Replacing a substring too broadly

A short literal can also occur inside longer identifiers. Enable whole-value boundaries or inspect every replacement count and output location.

Forgetting regex metacharacters

Dots, brackets, parentheses, and backslashes are syntax in regex mode. Use Literal text when the find value should have no pattern meaning.

Expanding replacement dollars unintentionally

Capture expansion interprets $1, $<name>, $&, and $$. Turn it off when those characters must be inserted literally.

Assuming regex flags are automatic

^ and $ are whole-input anchors until Multiline anchors is enabled, while dot excludes line endings until Dot matches newlines is enabled.

Ignoring zero-width insertion behavior

Zero-width patterns insert text without consuming source characters. Review the warning and output size before using lookarounds or anchors for insertion.

Examples

Replace only complete values

Literal, case-sensitive whole-value matching changes standalone cat but leaves category and underscored identifiers intact.

Input
cat category _cat cat_ cat
Output
animal category _cat cat_ animal

Reorder values with named captures

Regex capture expansion swaps comma-separated names with named groups while preserving each line ending.

Input
Doe, Jane
Kim, Min
Output
Jane Doe
Min Kim

Matching, capture, and reconstruction contract

Literal mode escapes the find value before constructing a global Unicode RegExp, so pattern metacharacters and replacement dollar tokens have no special meaning.

Regex mode always uses global and Unicode flags. Ignore-case, multiline anchors, and dot-all are added only when their visible controls are selected.

Whole-value filtering examines the Unicode code point on either side of each complete match and rejects adjacency to letters, numbers, combining marks, or underscore.

Optional capture expansion supports numbered groups, named groups, the whole match, and a literal dollar. Optional replacement escapes support only newline, carriage return, tab, and backslash.

Zero-width matches advance by one Unicode code point after evaluation. Accepted matches are rebuilt from untouched source slices, so line endings and nonmatched Unicode remain exact.

Input, setting, candidate, replacement, and output limits are enforced before or during O(n+m) reconstruction. Processing runs in a one-second module Worker and emits only numeric and option analytics.

Frequently Asked Questions

How do literal and regex modes differ?

Literal mode escapes every regex metacharacter and inserts replacement dollars literally. Regex mode executes a JavaScript pattern with global and Unicode flags plus the selected case, multiline, and dot-all flags.

What does whole-value boundary mean?

It rejects a candidate when the source character immediately before or after the complete match is a Unicode letter, number, combining mark, or underscore. It is more multilingual than ASCII \b but is still a documented code-point rule, not language-specific segmentation.

Which capture tokens are supported?

When capture expansion is enabled in regex mode, $1 through $99 use numbered groups, $<name> uses a named group, $& inserts the whole match, and $$ inserts one dollar sign.

How can a replacement insert a line break or tab?

Enable replacement escapes to convert \n, \r, \t, and \\. Any other backslash escape is rejected instead of guessed.

Can zero-width regex matches be replaced safely?

Yes. A lookahead or anchor can match without consuming text. The engine advances by a Unicode code point to prevent an infinite loop and reports the number of accepted zero-width matches.

Does replacement normalize Unicode or line endings?

No normalization or line-ending conversion is applied. Unmatched source slices remain exact; only accepted matches are replaced with the processed replacement value.

What are the safety and privacy limits?

Source text is limited to 1,048,576 UTF-8 bytes and 200,000 lines, find values to 16,384 bytes, replacements to 65,536 bytes, candidates to 50,000, and output to 2,097,152 bytes. A browser Worker stops after one second and analytics receives counts and options, not text.

How This Tool Was Verified

Maintained and tested by Reviewed

Method: Verification started with the guide's “Swap comma-separated names with named captures” fixture in Find and Replace Text. The run followed “Freeze and classify the source” through “Set flags and replacement semantics explicitly”, compared the produced result to the documented expectation, and checked the distinct limits behind “Using regex for a literal value” and “Trusting ASCII word boundaries for multilingual text”.

Expected result: The named-capture replacement changed exactly two comma-form names to Jane Doe and Min Kim, reported two candidates and two replacements, and preserved CRLF output.

Open the tested workflow

Related workflow guides

Use these focused guides when you need a practical workflow before opening the tool.

Workflow guide

Rename identifiers safely across code, data, and routes

Use a case converter to draft names, then treat every rename as a contract change: inventory consumers, define acronym rules, review invalid identifiers, compare a diff, and verify the destination.

Workflow guide

Test JavaScript regex against real multiline text

A multiline regex review needs the original line structure, a known pattern representation, deliberate flags, exact match and capture ranges, and a failing near-match. Run the native expression in an isolated worker, interpret offsets as UTF-16, and verify the final pattern again in the destination runtime before replacement or deployment.

Workflow guide

Fix JavaScript regex escaping across raw patterns and strings

Regex escaping is layered. First identify the source representation, decode only that representation, write the intended raw pattern body, and test it against exact positive and negative text. Then encode the verified body once for the destination JavaScript, JSON, or configuration format instead of adding backslashes by trial and error.

Workflow guide

Deduplicate lines from lists and logs without losing order

A practical workflow for turning repeated one-item-per-line data into an auditable unique list while preserving the first useful occurrence.

Workflow guide

Sort unique lines naturally before an import

A review-first workflow for producing a unique, naturally ordered list of IDs, names, URLs, tags, or labels without confusing sorting with normalization.

Workflow guide

Remove blank lines from pasted text without losing structure

A reviewable workflow for cleaning empty and whitespace-only rows while preserving the structure, order, and line-ending details that still matter.

Workflow guide

Remove line numbers from copied text without deleting real values

Use this workflow when code viewers, PDFs, transcripts, legal documents, or exported notes add numbers at the start of copied lines. Keep the source, distinguish marked numbering from ambiguous plain integers, compare cleanup evidence, and validate the result before reuse.

Workflow guide

Remove copied gutter numbers from a stack trace

Use the explicit Plain gutter format when an IDE, PDF, or documentation viewer copied a leading integer before every stack-trace line. Compare the result with the raw trace, preserve diagnostic values, redact secrets, and only then share it.

Workflow guide

Clean lists, logs, and copied text with a repeatable pipeline

Text cleanup is safest when it is treated as a sequence of explicit, reversible transformations. Preserve the source, identify line and delimiter boundaries, make one structural change at a time, promote only reviewed output to the next step, and compare the final text with the destination contract before publishing, importing, or sharing it.

Workflow guide

Replace text safely with regex captures and boundaries

A safe bulk-replacement workflow starts with an untouched source and the narrowest matching rule. It proves patterns separately, makes every flag and dollar token explicit, reviews boundary and zero-width diagnostics, compares the exact output, and tests the destination instead of treating a replacement count as correctness.

Workflow guide

Add fixed labels and delimiters to copied lines safely

Use this workflow for a plain list copied from a spreadsheet, report, log, or editor when every row needs the same label, marker, wrapper, or delimiter. It keeps line boundaries exact and separates bulk text insertion from JSON, CSV, SQL, shell, or HTML validation.

Related Tools

Continue with another maintained workflow

Browse All Tools