Regex Find and Replace — Free Online Tool
Overview
Find-and-replace with a regex is one of the most powerful text-manipulation operations — reformat dates (YYYY-MM-DD to DD/MM/YYYY), anonymize emails in log samples, restructure CSV columns, or strip HTML tags from content. This tool's replace mode shows the full output string in a preview panel alongside the match highlights, so you can verify before copying.
How to Use This Tool
Enter your pattern and set the g flag for global replacement. Paste your test string. Enable Replace mode using the toggle above the test string. Type your replacement in the Replacement field — use $1 for the first capture group. The output preview updates as you type.
Ready to get started? It's free, no registration required, and your files never leave your device.
PDF Tool →Frequently Asked Questions
How do I swap two capture groups in a replacement?
Use a pattern like (\w+)\s+(\w+) to capture two words, then write the replacement as $2 $1 to reverse their order. For example, matching 'John Doe' with this pattern and replacing as $2, $1 produces 'Doe, John'.
What is the $& replacement token?
$& inserts the entire matched string into the replacement. Useful for wrapping matches: a replacement of <b>$&</b> wraps every match in bold tags.
Can I use a function as the replacement?
This tool supports string replacements only (the second argument to String.prototype.replace()). Dynamic function-based replacements are not supported. For complex transformations, copy the pattern and implement it in your code editor.