Find and Replace
Free online tool to find specific strings in text and batch convert them to other strings.
How to Use
- Enter your text in the input area
- Type the text you want to find
- Enter the replacement text
- Choose options: case sensitive, whole word, or regex
- Click "Replace All" to replace all matches
Regex Examples
\d+- Match numbers\w+@\w+\.\w+- Match email addresseshttps?://\S+- Match URLs\s+- Match whitespace
Key Features
- Batch Find/Replace: Change all matches at once
- Case Sensitivity: Search with case distinction
- Whole Word Matching: Accurate matching considering word boundaries
- Regex Support: Powerful pattern matching
- Real-time Match Count: Display number of found matches
- Instant Copy: Copy results with one click
Option Description
Case Sensitive
Input: "Hello World, hello world"
Find: "hello"
Case Sensitive OFF: 2 matches (Hello, hello)
Case Sensitive ON: 1 match (hello only)
Whole Word
Input: "cat category catch"
Find: "cat"
Whole Word OFF: 3 matches (cat, cat in category, cat in catch)
Whole Word ON: 1 match (cat only)
Use Regex
When regex is enabled, powerful pattern matching is possible.
Regex Examples
1. Find Email Addresses
\w+@\w+\.\w+
Matches: user@example.com, admin@site.org
2. Find Phone Numbers
\d{3}-\d{4}-\d{4}
Matches: 010-1234-5678
3. Find URLs
https?://[^\s]+
Matches: http://example.com, https://site.com
4. Find Numbers Only
\d+
Matches: 123, 456, 789
5. Remove Spaces
Find: \s+
Replace: (empty string)
Result: All spaces removed
6. Change Line Breaks to Commas
Find: \n
Replace: ,
Result: Each line separated by comma
Practical Examples
Remove HTML Tags
Find: <[^>]+>
Replace: (empty string)
Input:
<p>Hello <strong>World</strong></p>
<div>Test</div>
Output:
Hello World
Test
Remove Duplicate Spaces
Find: \s{2,}
Replace: (one space)
Input:
Hello World Test
Output:
Hello World Test
Change Date Format
Find: (\d{4})-(\d{2})-(\d{2})
Replace: $2/$3/$1
Input:
2024-01-15
2024-12-31
Output:
01/15/2024
12/31/2024
Wrap in Quotes
Find: (\w+)
Replace: "$1"
Input:
apple banana cherry
Output:
"apple" "banana" "cherry"
Regex Syntax
Basic Characters
| Pattern | Description | Example |
|---|---|---|
. | Any single character | a.c → abc, adc |
\d | Digit (0-9) | \d+ → 123, 456 |
\w | Word character (a-z, A-Z, 0-9, _) | \w+ → hello, test_123 |
\s | Whitespace character | \s+ → space, tab, newline |
\D | Non-digit | \D+ → abc, xyz |
\W | Non-word character | \W+ → @#$, !&* |
\S | Non-whitespace | \S+ → hello, 123 |
Quantifiers
| Pattern | Description | Example |
|---|---|---|
* | 0 or more | ab*c → ac, abc, abbc |
+ | 1 or more | ab+c → abc, abbc |
? | 0 or 1 | colou?r → color, colour |
{n} | Exactly n | \d{3} → 123 |
{n,} | n or more | \d{2,} → 12, 123, 1234 |
{n,m} | Between n and m | \d{2,4} → 12, 123, 1234 |
Position Anchors
| Pattern | Description | Example |
|---|---|---|
^ | Start of line | ^Hello → "Hello World" |
$ | End of line | World$ → "Hello World" |
\b | Word boundary | \bcat\b → "the cat is" |
\B | Non-word boundary | \Bcat\B → "category" |
Groups and Ranges
| Pattern | Description | Example |
|---|---|---|
[abc] | One of a, b, c | [aeiou] → vowels |
[^abc] | Not a, b, or c | [^0-9] → not digits |
[a-z] | a through z | [a-zA-Z] → all letters |
(abc) | Capture group | (hello) world → group hello |
(?:abc) | Non-capture group | (?:hello) world |
| `a | b` | a or b |
Use Cases
1. Code Refactoring
# Batch variable name change
Find: oldVariableName
Replace: newVariableName
2. Data Cleaning
# Extract email addresses
Find: [a-zA-Z0-9._%+-]+@[a-zA-Z0-9.-]+\.[a-zA-Z]{2,}
3. Text Formatting
# Capitalize first letter of sentence (manually)
Find: ^(\w)
Replace: Change to uppercase
4. Log File Analysis
# Find error lines
Find: ERROR|FATAL
5. CSV Data Conversion
# Change comma to tab
Find: ,
Replace: \t
Precautions
-
Test Regex: Test complex regex in Regex Tester first.
-
Backup: Back up important data before find/replace.
-
Escape Special Characters: Characters with special meaning in regex must be escaped with
\:- Need escaping:
. * + ? ^ $ { } [ ] ( ) | \ - Example:
\(,\),\.,\*
- Need escaping:
-
Performance: Complex regex may be slow on very large text.
Frequently Asked Questions
Q: Can I find special characters without regex?
A: Yes, turn off the "Use Regex" option to find special characters as-is.
Q: Can I change case?
A: Not directly, but find and manually change or use a case conversion tool.
Q: Can I replace multiple patterns at once?
A: Use the OR operator (|) in regex:
Find: cat|dog|bird
Replace: animal
Q: Is line-by-line find/replace possible?
A: Yes, use ^ (line start) and $ (line end) in regex.
🔗 Try These Next
- Regex Tester - Test regex patterns
- Case Converter - Convert text case
- Text Comparison - Compare two texts
💬 Was this tool helpful?
Feel free to send us your feedback or suggestions anytime!
Performance
- Processing Speed: Milliseconds
- Supported Text Size: Unlimited (depends on browser memory)
- Regex Engine: JavaScript built-in RegExp
Privacy
This tool operates entirely on the client side. Your input text is never sent to a server and is processed only in your browser.