Find and Replace
Find and replace text with support for case-sensitive, whole-word, and regex matching. See match counts instantly.
This find and replace tool searches for text patterns and substitutes them across your content. It supports plain text matching, case-sensitive mode, whole-word matching, and full JavaScript regular expressions with capture group replacements. A live match counter shows how many occurrences will be affected before you run the replacement. All processing runs in your browser.
About Find and Replace
Matching Modes
| Mode | What It Does | Example |
|---|---|---|
| Default (case-insensitive) | Matches regardless of uppercase/lowercase | Searching "hello" matches "Hello", "HELLO", "hello" |
| Case-sensitive | Only matches the exact case | Searching "Hello" matches "Hello" but not "hello" or "HELLO" |
| Whole word | Matches only when the term appears as a complete word | Searching "cat" matches "cat" but not "category" or "concatenate" |
| Regex | Treats the search pattern as a JavaScript regular expression | Searching "\d+" matches any sequence of digits |
How Does Find and Replace Work?
In plain text mode, the tool scans your input from start to finish, looking for every occurrence of your search term. By default the search is case-insensitive, so "hello" matches "Hello" and "HELLO". Enabling case-sensitive mode restricts matches to the exact letter casing you typed. Whole-word mode wraps the search term in word boundaries so it only matches when it appears as a standalone word, stopping "cat" from matching inside "category" or "concatenate".
In regex mode, the search pattern is compiled as a JavaScript regular expression. The engine tries to match the pattern at each position in the text, using the rules defined by special characters like \d (any digit), \w (any word character), or . (any character). Replacements can reference captured groups using $1, $2, and so on, which makes it possible to rearrange or reformat matched text rather than just substituting it.
The replace-all operation applies a global flag, meaning every match in the text gets replaced in a single pass. Replace-next only changes the first match it finds, letting you step through occurrences one at a time. In both cases your original text stays untouched in the input field and the result appears separately below.
Regex Quick Reference
When regex mode is enabled, you can use the full JavaScript regular expression syntax:
| Pattern | Matches | Example |
|---|---|---|
| \d | Any digit (0-9) | \d+ matches "123", "42", "7" |
| \w | Word character (letter, digit, underscore) | \w+ matches "hello", "test_123" |
| \s | Any whitespace (space, tab, newline) | \s+ matches one or more spaces |
| . | Any character except newline | c.t matches "cat", "cut", "c3t" |
| [abc] | Any character in the set | [aeiou] matches any vowel |
| (group) | Captures a group for replacement with $1 | (\w+)@(\w+) captures email parts |
| ^ | Start of line | ^Hello matches "Hello" only at line start |
| $ | End of line | world$ matches "world" only at line end |
| * | Zero or more of the preceding | ab*c matches "ac", "abc", "abbc" |
| + | One or more of the preceding | ab+c matches "abc", "abbc" but not "ac" |
| ? | Zero or one of the preceding | colou?r matches "color" and "colour" |
How Do Capture Groups Work?
Capture groups are one of the most useful regex features for find and replace. Wrapping part of a pattern in parentheses () captures the matched text, and you can reference it in the replacement string with $1 for the first group, $2 for the second, and so on.
Example - reformatting dates. Suppose you have dates written as "15/04/2026" (DD/MM/YYYY) and need them in "2026-04-15" (YYYY-MM-DD) format. Set the find pattern to (\d{2})/(\d{2})/(\d{4}) and the replacement to $3-$2-$1. The first group captures the day (15), the second captures the month (04), and the third captures the year (2026). The replacement rearranges them into the target format.
Example - wrapping text in HTML tags. To wrap every word in bold tags, search for (\S+) and replace with <strong>$1</strong>. The group captures each non-whitespace sequence, and the replacement wraps it in the tag. This is handy for quick markup generation when preparing content for a web page.
Beyond numbered groups, JavaScript regex supports several replacement tokens:
| Token | What It Inserts |
|---|---|
| $1, $2, $3... | Contents of the numbered capture group |
| $<name> | Contents of a named capture group (?<name>...) |
| $& | The entire matched string |
| $` | Text before the match |
| $' | Text after the match |
| $$ | A literal dollar sign |
Named capture groups work in all modern browsers. Instead of (\d+), you can write (?<year>\d{4}) and reference it in the replacement as $<year>. Named groups make complex patterns much easier to read when you have three or more captures in a single expression.
Common Find and Replace Tasks
| Task | Find | Replace | Mode |
|---|---|---|---|
| Remove all numbers | \d+ | (empty) | Regex |
| Convert tabs to 4 spaces | \t | (4 spaces) | Regex |
| Remove blank lines | ^\s*\n | (empty) | Regex |
| Add quotes around words | (\w+) | "$1" | Regex |
| Swap first and last name | (\w+)\s(\w+) | $2 $1 | Regex |
| Convert dates from DD/MM to MM/DD | (\d{2})/(\d{2}) | $2/$1 | Regex |
| Remove HTML tags | <[^>]+> | (empty) | Regex |
| Normalise multiple spaces | \s{2,} | (single space) | Regex |
Data Cleaning Use Cases
Find and replace is one of the most common steps in data cleaning workflows. Before loading data into a spreadsheet, database, or analysis script, raw text often needs standardising.
Standardising terminology. Datasets pulled from multiple sources often contain inconsistent terms for the same thing. "United Kingdom", "UK", "U.K.", and "Great Britain" might all refer to the same country in a dataset. A simple plain-text replacement normalises these into a single consistent label before analysis.
Stripping unwanted characters. Text copied from PDFs, emails, or web pages frequently includes hidden characters like non-breaking spaces, zero-width joiners, or smart quotes. In regex mode, a pattern like [\u00A0\u200B\u200C\u200D\uFEFF] targets these invisible characters for removal. You can also strip leading and trailing whitespace from each line with ^\s+|\s+$.
Reformatting structured data. CSV exports sometimes have inconsistent delimiters, extra quotes, or trailing commas. A regex like ,\s*$ removes trailing commas from lines, while "([^"]*)" with replacement $1 strips surrounding quotes from fields. These small corrections are much faster than editing rows by hand.
Log file processing. Server logs and application output often need filtering before review. Extracting timestamps, removing debug-level entries, or converting date formats are all tasks that regex find and replace handles in seconds. For example, replacing (\d{4})-(\d{2})-(\d{2})T(\d{2}:\d{2}:\d{2}) with $1/$2/$3 $4 converts ISO 8601 timestamps into a more readable date-time format.
Common Mistakes to Avoid
Forgetting to escape special characters. Characters like ., *, +, ?, (, ), [, ], {, }, \, ^, and $ all have special meaning in regex. To match a literal period, search for \. instead of just .. This tool handles escaping automatically when regex mode is off, so plain text searches always work exactly as expected.
Greedy vs lazy matching. By default, quantifiers like * and + are greedy - they match as much text as possible. Searching for <.+> in the string <b>bold</b> matches the entire string from the first < to the last >, not just <b>. Adding ? after the quantifier (<.+?>) makes it lazy, matching the shortest possible string instead.
Catastrophic backtracking. Certain regex patterns cause the engine to try an exponential number of paths before determining there is no match. Patterns with nested quantifiers like (a+)+ or (.*a){10} are the usual culprits. OWASP classifies this as a Regular Expression Denial of Service (ReDoS) vulnerability, and it can freeze a browser tab for seconds or longer. If a regex search seems to hang, simplify the pattern by removing nested repetitions or using more specific character classes instead of the . wildcard.
Replacing more than intended. A common slip is forgetting to enable whole-word mode when replacing short strings. Replacing "is" with "was" in plain mode also changes "this" to "thwas" and "island" to "wasland". Whole-word mode prevents this by only matching "is" when it appears as a complete, standalone word with boundaries on both sides.
How It Differs from Code Editor Find/Replace
| Feature | This Tool | VS Code / IDE |
|---|---|---|
| Non-destructive | Original text stays in input, result shown separately | Modifies the file directly (Ctrl+Z to undo) |
| Live match count | Yes - updates as you type the search pattern | Yes |
| Multi-file search | No - single text block | Yes - across entire project |
| Regex support | JavaScript regex | JavaScript regex (VS Code), varies by IDE |
| No installation | Runs in browser | Requires IDE installation |
This tool is useful when you need a quick replacement without opening an editor - for cleaning data exports, reformatting log output, or transforming text copied from elsewhere. For bulk replacements across many files, a code editor or command-line tool like sed is better suited.
To test regex patterns with detailed match highlighting and group extraction, try the regex tester. For comparing text before and after edits, the text diff tool highlights every difference side by side. If you need to convert between naming conventions like camelCase, snake_case, or UPPER_CASE, the case converter handles that in one click.
Sources
Frequently Asked Questions
Does the tool support regular expressions?
Yes. Toggle regex mode on and your search pattern will be treated as a JavaScript regular expression. This lets you use patterns like '\d+' to match numbers, '\bword\b' for whole-word boundaries, and capture groups with parentheses for advanced replacements using $1, $2 syntax.
What does the whole-word option do?
When whole-word matching is enabled, the search term only matches when it appears as a complete word - not as part of a longer word. Searching for 'cat' will match 'cat' but not 'category' or 'concatenate'. This is implemented using word-boundary markers.
Can I undo a replacement?
The tool does not modify your original text in place. Your source text stays in the input field, and the result of the replacement appears separately. You can adjust your find and replace terms and run the operation again without losing the original.
Is there a limit on the amount of text I can process?
The tool runs entirely in your browser, so there is no server-imposed limit. Performance depends on your device, but it handles documents of tens of thousands of words without issue. Very large texts with complex regex patterns may take a moment to process.
Link to this tool
Copy this HTML to link to this tool from your website or blog.
<a href="https://toolboxkit.io/tools/find-and-replace/" title="Find and Replace - Free Online Tool">Try Find and Replace on ToolboxKit.io</a>