Find & Replace
Find and replace text with plain text or regex patterns. Supports case-insensitive matching.
Find and Replace Tool lets you search for text patterns within a body of text and replace them with something else β all within your browser with no installation needed. While most text editors have built-in find/replace functionality, this standalone tool is useful when working with text in environments that lack this feature, or when you need to share or document a specific replacement operation.
Enter the search term and replacement text, then click Replace All to substitute every match at once, or use Replace Next to step through matches one at a time. The tool supports case-sensitive and case-insensitive matching, whole-word matching (to avoid replacing "cat" within "concatenate"), and regular expression (regex) mode for complex pattern matching. With regex mode, you can match patterns like all digits, all email addresses, or specific HTML tags.
Regular expressions are a powerful way to find and replace content that follows a pattern rather than exact text. For example, you can find all dates in YYYY-MM-DD format and reformat them as DD/MM/YYYY in one operation. The regex syntax supported here follows the standard JavaScript regular expression engine, the same engine used in Chrome DevTools, Visual Studio Code, and many other tools.
Frequently Asked Questions
Code Implementation
import re
def find_replace(text: str, find: str, replace: str,
use_regex: bool = False, case_sensitive: bool = True) -> str:
"""Find and replace text, with optional regex and case-insensitive modes."""
if use_regex:
flags = 0 if case_sensitive else re.IGNORECASE
return re.sub(find, replace, text, flags=flags)
else:
if case_sensitive:
return text.replace(find, replace)
else:
# Case-insensitive plain string replace
return re.sub(re.escape(find), replace, text, flags=re.IGNORECASE)
# Examples
text = "Hello World. Hello Python."
print(find_replace(text, "Hello", "Hi"))
# Hi World. Hi Python.
print(find_replace(text, r"\bHello\b", "Greetings", use_regex=True))
# Greetings World. Greetings Python.
print(find_replace(text, "hello", "Hi", case_sensitive=False))
# Hi World. Hi Python.
Comments & Feedback
Comments are powered by Giscus. Sign in with GitHub to leave a comment.