String Manipulation Tool — Transform, Clean & Encode Text Online

Find and Replace Online

Find and replace text with regex support. Replace literal strings or use regex patterns with configurable flags.

100% client-side. Your data never leaves your browser.

Send to:

Related Tools

Find and Replace Online

This example demonstrates the find and replace operation from String Tools, pre-loaded with a simple replacement scenario. Paste any text, enter a search pattern (literal or regex), and specify the replacement string. The output updates instantly as you type.

How It Works

The tool splits your input into lines and applies the search/replace operation across the entire text. When regex mode is enabled, the search field is interpreted as a regular expression pattern. The replacement field can include backreferences ($1, $2) to reference captured groups.

Literal vs Regex Matching

In literal mode, special characters lose their regex meaning. A search for file.txt matches exactly those characters. In regex mode, the dot matches any single character, so file.txt would also match file1txt or fileAtxt.

Common Regex Patterns for Find and Replace

PatternUse Case
\\s+Match one or more whitespace characters
\\bword\\bMatch whole word only
(?i)patternCase-insensitive match (or use the flag toggle)
(capture)Capture a group for use in replacement
[^a-zA-Z]Match any non-letter character

Practical Example: Cleaning CSV Data

Say you have comma-separated values with inconsistent spacing:

name , age , city
Alice , 30 , New York
Bob , 25 ,San Francisco

Search for \\s*,\\s* (comma surrounded by optional whitespace) and replace with , to normalize all separators. Then search for ^\\s+|\\s+$ with the multiline flag to trim leading and trailing spaces from each line.

How to Use

  1. Paste your text into the input area
  2. Enter the search pattern in the search field (literal text or regex)
  3. Enter the replacement string (use $1, $2 for captured groups)
  4. Toggle regex mode, global replace, or case-insensitive flags as needed
  5. Copy the transformed output from the result area

Common Questions

Can I preview replacements before copying?

Yes. The tool shows the transformed output in real time. Each replacement is reflected immediately so you can verify the result before copying it.

How do I escape special regex characters?

Wrap your search text in the regex escape sequence: each special character (. * + ? [ ] ( ) { } ^ $ | \) should be preceded by a backslash. Or use literal mode, which treats all characters as plain text.

What happens with empty matches?

If a regex pattern matches an empty string (e.g., a*), the tool replaces each empty match and moves forward, which can produce unexpected results. Use a+ instead to require at least one character.