Regex Replace

Replace text with regular expressions online, with replacement templates, capture group references, named groups, and flag controls.

Flags
Current PatternEnter a pattern to begin replacing.
Replace ModeReplace all matches
Replacement Count0 replacements
Output Length0 characters

Replacement Template Tips

  • $1 References capture group 1, 2, and so on.
  • $& References the full current match.
  • $<name> References a named capture group value.
  • $$ Outputs a literal dollar sign.

Replacement Details

Review how each match was transformed by the replacement template.

Replacement details will appear here after the pattern finds matches.

Common Replacement Presets

Load a preset to try typical regex replacement workflows.

Reformat Dates

Turn YYYY-MM-DD into MM/DD/YYYY.

Pattern(\d{4})-(\d{2})-(\d{2})
Replacement$2/$3/$1
Source TextPublished: 2024-10-05 Backup: 2025-01-14
Mask Email Addresses

Keep the first character and domain while hiding the rest of the username.

Pattern(?<user>[A-Za-z0-9._%+-])[A-Za-z0-9._%+-]*@(?<domain>[A-Za-z0-9.-]+\.[A-Za-z]{2,})
Replacement$<user>***@$<domain>
Source Texthelp(at)example.com support(at)toolmi.com
Collapse Whitespace

Convert repeated spaces, tabs, and line breaks into a single space.

Pattern\s+
Replacement
Source TextToolMi makes text cleanup easier.
Numbered List to Bullets

Convert ordered steps into Markdown bullet points.

Pattern^(\d+)\.\s+(.+)$
Replacement- $2
Source Text1. Install dependencies 2. Run the build 3. Deploy the app

Tool Overview: Regex Replace

Regex Replace lets you transform text in the browser with JavaScript regular expressions. It supports replacement templates such as $1, $2, $&, and $<name>, making it useful for masking, cleanup, and text restructuring tasks.

Supported Features

  • Batch text replacement with regex
  • Capture group and named group references
  • g / i / m / s / u / y flag controls
  • Per-match replacement details
  • Copy and download output

How To Use

  1. Enter a regex pattern and replacement template.
  2. Toggle the flags you need.
  3. Paste the source text.
  4. Review the replaced output and per-match details.
  5. Copy or download the final result.

Common Use Cases

  • Reformat dates
  • Mask email addresses, phone numbers, or log fields
  • Collapse repeated whitespace
  • Convert text structures into Markdown or other formats