replace_in_file
Search and replace all occurrences of a regex pattern with a target string in a file, enabling precise content modifications with optional single-match enforcement.
Instructions
Replace all occurrences of a regex pattern with a target string in a file.
Input Schema
Name | Required | Description | Default |
---|---|---|---|
file_path | Yes | Absolute path to the file | |
multiple | No | Allow multiple replacements. If false, fails if multiple matches found. | |
regex_source | Yes | Regular expression pattern to search for | |
target | Yes | String to replace matches with |
Input Schema (JSON Schema)
{
"$schema": "http://json-schema.org/draft-07/schema#",
"additionalProperties": false,
"properties": {
"file_path": {
"description": "Absolute path to the file",
"type": "string"
},
"multiple": {
"description": "Allow multiple replacements. If false, fails if multiple matches found.",
"type": "boolean"
},
"regex_source": {
"description": "Regular expression pattern to search for",
"type": "string"
},
"target": {
"description": "String to replace matches with",
"type": "string"
}
},
"required": [
"file_path",
"regex_source",
"target"
],
"type": "object"
}