JSON TransformString
replaceAll
Replace every occurrence of a substring
replaceAll
Replaces every occurrence of pattern with replacement in a string.
Options
| Option | Type | Required | Default | Description |
|---|---|---|---|---|
pattern | string | Yes | — | Literal substring to find. |
replacement | string | Yes | — | Substring to insert in place of each match. |
Example
Input
"foo bar foo"Operation
{ "type": "replaceAll", "options": { "pattern": "foo", "replacement": "qux" } }Output
"qux bar qux"In a Circuit Step
{
"name": "scrub_placeholders",
"description": "Replace every `{{name}}` placeholder with the actual user name",
"function": "circuit.core.transform.json",
"input": {
"source": "${{ input.template }}",
"operations": [
{
"type": "replaceAll",
"options": {
"pattern": "{{name}}",
"replacement": "${{ input.user_name }}"
}
}
]
},
"outputs": [
{
"name": "rendered_template",
"description": "Template with all `{{name}}` placeholders replaced",
"value": "${{ scrub_placeholders.output.transformed_result }}"
}
]
}Notes & gotchas
- Errors with
replaceAll: expected stringif the input is not a string. patternis treated as a literal substring, not a regex.- An empty
patternwill insertreplacementbetween every character — match Rust'sString::replacesemantics. - For first-only replacement, use
replace.