Regex Replace

Rewrite structured text locally with JavaScript regex patterns, flags, capture groups, and replacement backreferences.

Regex Pattern
Replace With
Test Text
Match Preview
Matches will appear here...
0 characters 0 matches

What does Regex Replace do?

Regex Replace finds text patterns and replaces matches using JavaScript regular expressions.

  • Primary use: Regex Replace finds text patterns and replaces matches using JavaScript regular expressions.
  • Key technical fact: Replacement strings can use capture groups, making regex replace useful for structured text rewrites.
  • Practical check: Review Unicode, whitespace, line break, and punctuation behavior before treating the output as production text.
Topic Direct answer Source
Direct answer Regex Replace finds text patterns and replaces matches using JavaScript regular expressions. ECMAScript specification
Key fact Replacement strings can use capture groups, making regex replace useful for structured text rewrites. ECMAScript specification
Processing model Runs locally in the browser; no production Node server receives the input. Browser JavaScript

Rewrite structured text with regex backreferences

Regex Replace searches text with a JavaScript regular expression and replaces each match with a replacement string. It is useful for reformatting dates, normalizing IDs, trimming repeated labels, reshaping CSV-like text, and testing cleanup rules before using them in scripts.

Capture groups can be reused in the replacement with backreferences such as $1, $2, and $& for the whole match. The selected flags affect how many matches are found and how anchors, case, dots, and Unicode are interpreted.

How to use

  1. Type or paste a regex pattern into the Regex Pattern field. No delimiters needed.
  2. Select the flags you need: g (global), i (case-insensitive), m (multiline), s (dotAll), u (unicode), or y (sticky).
  3. Enter a replacement string in the Replace With field. Use $1, $2 for backreferences to captured groups.
  4. Paste or type your test text into the editor below. Matches are highlighted as you type.
  5. Click Replace All to apply the replacement to the entire text.
  6. Use Copy to copy the result, Download to save it, or Clear to reset everything.

What is Regex Replace?

Regex Replace is a local find-and-replace sandbox for JavaScript regular expressions. It shows matching text before you apply the replacement, which helps catch overbroad patterns before they rewrite too much.

Replacement syntax is JavaScript syntax. If you are moving the expression to another language or editor, verify group numbering, named-group support, escaping, newline handling, and whether replacement backreferences use $1, \1, or another form.

Input notes

Test on a small representative sample before pasting large text. Use capture groups only around the parts you need later, escape literal characters such as dots and parentheses, and review the preview before clicking Replace All.

Example

Capture groups can rearrange dates from MM/DD/YYYY into ISO-style YYYY-MM-DD output:

--- Pattern ---
(\d{2})/(\d{2})/(\d{4})

--- Replacement ---
$3-$1-$2

--- Flags ---
g (global)

--- Test Text ---
Today is 04/29/2026 and tomorrow is 04/30/2026.

--- Result ---
Today is 2026-04-29 and tomorrow is 2026-04-30.

MCP integration

MCP (Model Context Protocol) lets AI agents and apps discover and run Coding.Tools utilities for repeatable conversions, formatting, hashing, and generation workflows.

MCP tool name: regex-replace

MCP endpoint: https://coding.tools/mcp

Call tools/list first. Each tool entry includes inputSchema, outputSchema, and examples so an AI agent or client can build valid arguments without guessing.

For tools/call, read result.content[0].text for the display value and result.structuredContent for machine parsing. Tool-level failures return isError: true; protocol failures return a JSON-RPC error.

Example tools/call request:

curl -s https://coding.tools/mcp \
  -H "Content-Type: application/json" \
  -H "Accept: application/json" \
  -H "MCP-Protocol-Version: 2025-06-18" \
  -d '{"jsonrpc":"2.0","id":1,"method":"tools/call","params":{"name":"regex-replace","arguments":{"input":"Ticket ABC-123 is ready for review","options":{"pattern":"[A-Z]{3}-\\d{3}","replacement":"[ticket-id]","flags":"g"}}}}'

Most text and data tools accept an input string plus optional options. Browser-only image tools are listed for discovery and return a web UI link when they need browser image APIs.