• EasyStackTools189+ Free Tools
  • EVM Tools
    • Word Counter
    • Character Counter
    • Text Case Converter
    • Slug Generator
    • Remove Duplicate Lines
    • Lorem Ipsum Generator
    • Reverse Text
    • Remove Extra Spaces
    • Line Break Remover
    • Word Frequency Counter
    • Randomcase Text
    • Invert Text Case
    • Repeat Text
    • Replace Text
    • Truncate Text
    • Trim Text
    • Left-Pad Text
    • Right-Pad Text
    • Rotate Text
    • Circularly Rotate Text Left
    • Circularly Rotate Text Right
    • Delete Empty Lines
    • Shuffle Text Lines
    • Reverse Text Lines
    • Convert Spaces to Tabs
    • Convert Tabs to Spaces
    • Center Text
    • Right-Align Text
    • Justify Text
    • Word Wrap
    • Split into Words
    • Number Text Lines
    • Prefix Text Lines
    • Suffix Text Lines
    • Prefix and Suffix Text Lines
    • Join Text Lines
    • Split Strings
    • Find Longest Text Line
    • Find Shortest Text Line
    • Format Text Columns
    • Sort Text
    • Sort Numbers
    • Sort Words
    • Sort Text by Length
    • Sort IP Addresses
    • Filter Text Lines
    • Grep Text
    • Head Text
    • Tail Text
    • Extract Line Range
    • Find Letter Frequency
    • Find Phrase Frequency
    • Extract All Emails
    • Extract All URLs
    • Extract All Numbers
    • Text Statistics
    • Convert Text to Binary
    • Convert Binary to Text
    • Convert Text to Octal
    • Convert Octal to Text
    • Convert Text to Decimal
    • Convert Decimal to Text
    • Morse Code
    • UTF-8 Encode/Decode
    • Base32 Encode/Decode
    • Uuencode / Uudecode
    • Strip HTML Tags
    • Convert Text to HTML Entities
    • Remove Text Character Accents
    • Remove Text Punctuation
    • Add Thousands Separators
    • Add Backslashes
    • Strip Backslashes
    • Extract Regex Matches
    • Replace Regex Matches
  1. Home
  2. Text Tools
  3. Replace Regex Matches

Replace Regex Matches

Replace all regex matches with a replacement string. Use $1, $2 for capture groups. Full regex replace.

Read the guide

Result

Output will appear here...

Guide and examples

Replacing all regex matches in text usually means writing a script or using an editor. The Replace Regex Matches tool does it in the browser: paste text, enter a regex and replacement (with $1, $2 for capture groups), and get the transformed text—no sign-up and no data sent to a server.

What does Replace Regex Matches do?

Replace Regex Matches is a free online tool that finds all matches of a regex in your text and replaces them with a replacement string. You can use $1, $2 for capture groups and $& for the full match. Capture groups in replacement: use $1, $2, etc. for capture groups; $& for full match. Use it to transform text with patterns (e.g. swap date format, wrap matches, or replace only certain substrings that match a rule). All processing happens in your browser.

Key Features

  • Full regex replace — Paste or type text, enter a regex pattern, and enter the replacement string. Invalid regex will show an error.
  • Capture groups — Yes. Use $1, $2, etc. for capture groups. $& for full match. Capture groups must exist in the pattern (use parentheses). $1 is the first group, $2 the second. Literal $ in replacement may need escaping.
  • Any input — Paste or type text. No size limit for in-browser processing.
  • Instant result — Paste, enter pattern and replacement, view result. Copy when ready.
  • Privacy-first — All processing happens in your browser. Your text is never sent to any server.
  • No account — Use as often as you need without sign-up.

How to Use Replace Regex Matches

  1. Open the Replace Regex Matches tool.
  2. Paste or type your text. Enter a regex pattern and replacement string (use $1, $2, $& as needed).
  3. View the transformed text. Copy when ready. Use the "Use tool" button on the docs page if you are reading this from the documentation.

Real Use Cases

  • Swap date format — Match (\d)-(\d)-(\d) and replace with $3/$2/$1 to get DD/MM/YYYY from YYYY-MM-DD.
  • Wrap matches — Replace a pattern with a prefix and $& and suffix (e.g. wrap every number in brackets).
  • Replace only certain substrings — Use a pattern that matches only what you want to change (e.g. replace only standalone digits, or only words that match a rule).
  • Normalize text — Replace multiple spaces, fix punctuation, or standardize formats (e.g. phone, IDs) with one pattern.
  • Template-style replace — Use capture groups to reorder or format (e.g. "Last, First" → "First Last" with $2 $1).
  • Test regex — Verify pattern and replacement before using in code. Use Extract Regex Matches to see matches first if needed.

Why Use Replace Regex Matches Instead of Alternatives?

  • vs. Replace Text — Replace Text does literal find-and-replace. This tool uses regex and supports capture groups. Use regex when you need patterns.
  • vs. Extract Regex Matches — Extract Regex Matches returns the list of matches. This tool returns the full text with matches replaced. Use the one that matches your goal.
  • vs. Grep Text — Grep Text filters lines. This tool replaces within text. Use both as needed.
  • vs. Scripts — No coding. Works in any browser.

If $1 or $2 is not replaced, capture groups must exist in the pattern (use parentheses). $1 is the first group, $2 the second. Literal $ in replacement may need escaping.

Benefits for Developers, Editors, and Data Users

  • Developers — Transform logs, configs, or output with regex without writing a script.
  • Editors — Batch-replace with patterns (e.g. format all dates, wrap all links).
  • Data users — Normalize or reformat text for import or reporting.

Common Mistakes

  • $1 or $2 not replaced — Capture groups must exist in the pattern (use parentheses). $1 is the first group, $2 the second. Literal $ in replacement may need escaping.
  • Invalid regex — The tool will show an error. Fix the pattern and try again.
  • Expecting extract only — This tool replaces. For a list of matches use Extract Regex Matches.
  • Forgetting to copy — The result is not saved. Copy before closing the tab.

Frequently Asked Questions

What does replace regex matches do?

It finds all matches of a regex in your text and replaces them with a replacement string. You can use $1, $2 for capture groups and $& for the full match.

Can I use capture groups in replacement?

Yes. Use $1, $2, etc. for capture groups. $& for full match.

What input does it accept?

Paste or type text, enter a regex pattern, and enter the replacement string. Invalid regex will show an error.

Is my text stored?

No. All processing happens in your browser. Your text is never sent to any server.

When should I use replace regex?

Use it to transform text with patterns (e.g. swap date format, wrap matches, or replace only certain substrings that match a rule).

Why is $1 or $2 not replaced?

Capture groups must exist in the pattern (use parentheses). $1 is the first group, $2 the second. Literal $ in replacement may need escaping.

Conclusion and Try the Tool

Replace Regex Matches gives you pattern-based replace in seconds: paste, enter pattern and replacement, copy. No account, no server round-trip. For literal replace use Replace Text, for listing matches use Extract Regex Matches, and for line-based match use Grep Text.

Use the Replace Regex Matches tool to find and replace with regex.

Frequently Asked Questions

It finds all matches of a regex in your text and replaces them with a replacement string. You can use $1, $2 for capture groups and $& for the full match.

Related Tools

  • Replace Text

    Find and replace text with optional regex support. Replace first match, all matches, or use regular expressions.

  • Extract Regex Matches

    Extract all regex matches from text. Show each match on a new line. Optional capture groups. Test and extract.

  • Grep Text

    Search text for lines matching a pattern. Regex support. Show only matching lines or show line numbers.

  • Word Counter

    Free online word counter tool. Count words, characters, sentences, and paragraphs instantly. Perfect for writers, students, and SEO professionals.