Free Online Regex Replace Tool
Quick Tips
- • This tool runs entirely in your browser - your data stays private.
- • Press Ctrl+V (Cmd+V on Mac) to quickly paste text.
- • Use the Copy button to save your result to clipboard.
- • Bookmark this page for quick access!
Replace text using regular expression patterns.
Examples
Pattern: (\d{2})/(\d{2})/(\d{4})
Replace: $3-$1-$2
Text: 12/25/2024
2024-12-25
Pattern: (\w+), (\w+) Replace: $2 $1 Text: Smith, John
John Smith
Pattern: <[^>]+> Replace: (empty) Text: <b>Hello</b>
Hello
Pattern: (\w+)@(\w+\.\w+) Replace: [$1 at $2] Text: user@domain.com
[user at domain.com]
Frequently Asked Questions
Backreferences let you include captured groups from your match in the replacement. Use parentheses in your pattern to capture portions of the match, then reference them as $1, $2, $3, etc. in the replacement string.
Wrap the portion you want to capture in parentheses. For example, (\d+)-(\d+) captures two number sequences. The first is $1 and the second is $2 in your replacement.
Yes, you can use backreferences in any order. If your pattern captures (First) (Last), your replacement can be $2, $1 to output Last, First. This is perfect for reformatting data.
Use $$ to insert a literal dollar sign in your replacement text. Since $ is used for backreferences, you need to escape it when you want the actual character.
If a capture group is optional and does not match for a particular occurrence, the backreference typically produces an empty string. Design your patterns to handle optional captures appropriately.
Yes, the tool uses JavaScript regular expression syntax and behavior, making it ideal for web developers testing patterns they will use in their code.
Related Tools
Related Articles
Mastering Find and Replace in Text
Learn powerful find and replace techniques including regex for efficient text editing.
Read moreRegular Expressions Guide for Beginners
Learn the basics of regular expressions (regex) for powerful text pattern matching.
Read moreUnix Timestamp Conversion: A Developer Guide
Learn to convert between Unix timestamps and human-readable dates in various programming languages.
Read more