— Regex Replace Text

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

Input
Pattern: (\d{2})/(\d{2})/(\d{4})
Replace: $3-$1-$2
Text: 12/25/2024
Output
2024-12-25
Input
Pattern: (\w+), (\w+)
Replace: $2 $1
Text: Smith, John
Output
John Smith
Input
Pattern: <[^>]+>
Replace: (empty)
Text: <b>Hello</b>
Output
Hello
Input
Pattern: (\w+)@(\w+\.\w+)
Replace: [$1 at $2]
Text: user@domain.com
Output
[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.

Cookie Preferences

We use cookies to enhance your experience. By continuing to visit this site you agree to our use of cookies.

Cookie Preferences

Manage your cookie settings

Essential Cookies
Always Active

These cookies are necessary for the website to function and cannot be switched off. They are usually set in response to actions made by you such as setting your privacy preferences or logging in.

Functional Cookies

These cookies enable enhanced functionality and personalization, such as remembering your preferences, theme settings, and form data.

Analytics Cookies

These cookies allow us to count visits and traffic sources so we can measure and improve site performance. All data is aggregated and anonymous.

Google Analytics _ga, _gid

Learn more about our Cookie Policy