# Text replace exact

`text-replace-exact` · version 1.0.0 · Text · free, no key needed

Replace exact UTF-16 substrings without regex, case folding, or Unicode normalization.

**Use when you need to: text replace exact · exact substring replacement · replace exact text matches.**

## Supported

- text replace exact
- exact substring replacement
- replace exact text matches

## Not supported

- regex replacement
- case-insensitive replace
- unicode normalization
- fuzzy matching
- read files

## Behavior

- Matching is exact UTF-16 code-unit equality of the search string inside text.
- Matches are non-overlapping and consumed left to right; the search is never re-scanned inside a replacement.
- An empty search is rejected because it would match unbounded positions.
- If max_replacements is omitted, every non-overlapping match is replaced; otherwise at most that many substitutions occur.
- Replacement is a literal string; $ sequences are not interpolations.
- No case folding, locale compare, or Unicode normalization is performed.
- The output text must not exceed 1,048,576 UTF-8 bytes.

## Input

- `text` (string, required): max length 262144
- `search` (string, required): min length 1; max length 65536
- `replacement` (string, required): max length 65536
- `max_replacements` (integer, optional): min 1; max 1000000

## Output

- `text` (string, required): max length 1048576
- `replacements` (integer, required): min 0

## Limits

- max text bytes: 262144
- max search bytes: 65536
- max replacement bytes: 65536
- max output bytes: 1048576
- max replacements: 1000000

## Example

Request input:

```json
{
  "text": "the cat sat on the mat",
  "search": "at",
  "replacement": "ot"
}
```

Response:

```json
{
  "result": {
    "text": "the cot sot on the mot",
    "replacements": 3
  }
}
```

## How to call it

### MCP

Connect `https://computefirst.net/mcp` ([setup](/docs#connect)), then call `execute` with:

```json
{
  "id": "text-replace-exact",
  "version": "1.0.0",
  "input": {
    "text": "the cat sat on the mat",
    "search": "at",
    "replacement": "ot"
  }
}
```

### HTTP (no key)

```sh
curl -X POST https://computefirst.net/v1/tools/text-replace-exact/versions/1.0.0/execute \
  -H "Content-Type: application/json" \
  -d '{"text":"the cat sat on the mat","search":"at","replacement":"ot"}'
```

The machine-readable contract is at [/v1/tools/text-replace-exact/versions/1.0.0](/v1/tools/text-replace-exact/versions/1.0.0).

### CLI

```sh
node cli.mjs run text-replace-exact 1.0.0 --input input.json --base-url https://computefirst.net
```

Get the client at [/clients/cli/](/clients/cli/).

## Related tools

- [Text split exact](/tools/text-split-exact): Split text on an exact literal separator and reject results that exceed max_parts.
- [Text extract between](/tools/text-extract-between): Extract exact substrings between start and end markers, left to right and non-overlapping.
- [Text slice codepoints](/tools/text-slice-codepoints): Slice a string by Unicode code-point indexes, not UTF-16 code units.
- [Text tabs to spaces](/tools/text-tabs-to-spaces): Convert tab characters to spaces.
- [Text apply unified patch](/tools/text-apply-unified-patch): Apply a one-file unified patch to text at original line addresses with exact hunk matches.
- [Text conflict parse](/tools/text-conflict-parse): Parse merge or diff3 conflict-marker text into ordered text and conflict parts.
