Find & Replace
Find and replace online with regex support. Search and replace text patterns, preview matches before applying. Free regex replace tool.
Text
Features
- Find and replace with regex support
- Case-sensitive and case-insensitive search
- Global replace or first match only
- Preview matches before replacing
- Match count and statistics
- Regex pattern validation and testing
Common Use Cases
- Replace all occurrences of old API endpoints
- Remove sensitive data from logs
- Convert date formats in text
- Clean up malformed CSV data
- Batch rename variables in code snippets
Find and Replace with Regular Expressions
Find and replace allows you to search for text patterns and replace them with new text. With regex (regular expressions), you can match complex patterns, not just exact strings.
Common regex patterns:
\d+- One or more digits (e.g., "123")\w+- One or more word characters[a-z]+- One or more lowercase letters.*- Any characters (greedy match)(group)- Capture group for use in replacement
Replacement patterns: Use $1, $2 to reference captured groups. For example, find (\d+)-(\d+) and replace with $2-$1 to swap two numbers.
Examples
Find: http://example.com
Replace: https://example.com
β Updates all HTTP to HTTPSFind: (\d{3})(\d{3})(\d{4})
Replace: ($1) $2-$3
β "1234567890" becomes "(123) 456-7890"Find: \s+
Replace: " " (single space)
β Collapses multiple spacesFrequently Asked Questions
Regex (regular expressions) is a powerful pattern-matching language. Instead of finding exact text, you can find patterns like "any email address" or "all phone numbers". It's essential for advanced text processing.
Use $1, $2, etc. For example, if you capture email with (\w+)@(\w+\.com), you can reverse it with $2 - $1 in the replacement field.
Global replaces all occurrences in the text. Without global, only the first match on each line is replaced. Always use global unless you specifically want to replace only the first match.
Yes! The tool shows a preview of what will be changed, with matches highlighted. This prevents accidental destructive replacements.
Use backslash (\) before special characters like . * + ? [ ] ( ) { } ^ $ |. For example, to match a literal period, use \.
π‘ Tips
- Test your regex pattern on a small sample first before running it on large textβregex mistakes can be destructive
- Use the preview feature to verify matches before clicking Replaceβit shows exactly what will change
- Common mistake: forgetting to escape special characters like periods (.) which match ANY character in regex
- For complex replacements, break them into multiple stepsβdo one find/replace, verify, then continue