Skip to content
PithLab

↑↓ to move · Enter to open · Esc to close

Find and Replace API

Find and replace in text, as plain text or a JavaScript regular expression, with case sensitivity and whole-word options. Returns the result and match counts.

POST /api/v1/tools/find-and-replaceMCP find_and_replaceText & Writing

Find and replace words or phrases in any text, with case-sensitive, whole-word and regular-expression options. Shows how many matches were replaced.

Input

Send these as a JSON object. Unknown fields are rejected.

input
The text to search. (string, up to 100000 characters, required)
find
Text or regular expression (without slashes) to search for. (string, up to 500 characters, required)
replace
Replacement. In regex mode $1, $<name> and $& refer to groups; in plain mode it is inserted literally. (string, up to 10000 characters, default "")
regex
Treat find as a JavaScript regular expression. Runs with a 1 second time limit, so patterns that backtrack heavily, such as (a+)+b, fail with an error. (boolean, default false)
caseSensitive
Match case exactly. (boolean, default false)
wholeWord
Only match where the search is not part of a longer word. (boolean, default false)
replaceAll
Replace every match; false replaces only the first. (boolean, default true)
curl https://pithlab.com/api/v1/tools/find-and-replace \n  -H "Authorization: Bearer $PITHLAB_KEY" \n  -H "Content-Type: application/json" \n  -d '{"input":"Colour, colour and more COLOUR.","find":"colour","replace":"color"}'
Example response
{
  "ok": true,
  "result": {
    "output": "color, colour and more COLOUR.",
    "matches": 3,
    "replaced": 1
  }
}