Replace
Synopsis
Performs string replacement operations with case-sensitive and case-insensitive options.
Schema
- replace:
field: <ident>
pattern: <string>
replacement: <string>
target_field: <string>
replace_all: <boolean>
case_sensitive: <boolean>
description: <text>
if: <script>
ignore_failure: <boolean>
ignore_missing: <boolean>
on_failure: <processor[]>
on_success: <processor[]>
tag: <string>
Configuration
The following fields are used to define the processor:
Field | Required | Default | Description |
---|---|---|---|
field | Y | - | Source field containing string to process |
pattern | Y | - | String pattern to search for |
replacement | Y | - | String to replace matched pattern with |
target_field | N | Same as field | Target field to store result |
replace_all | N | true | Replace all occurrences (false = replace first only) |
case_sensitive | N | true | Case-sensitive pattern matching |
description | N | - | Explanatory note |
if | N | - | Condition to run |
ignore_failure | N | false | Continue processing if replacement fails |
ignore_missing | N | false | Skip processing if referenced field doesn't exist |
on_failure | N | - | See Handling Failures |
on_success | N | - | See Handling Success |
tag | N | - | Identifier |
Details
Performs literal string replacement operations with flexible matching options. The processor supports both case-sensitive and case-insensitive matching with options to replace all occurrences or just the first match.
The processor supports template substitution in the pattern field, allowing dynamic pattern matching based on other field values. The replacement string is used literally without template processing.
This processor performs literal string matching, not regular expression matching. For pattern-based replacements with wildcards or regex patterns, use the regex-replace processor instead.
When case_sensitive
is disabled, the processor performs case-insensitive matching while preserving the original case of surrounding text. Only the matched portion is replaced.
If the pattern is an empty string, the processor skips replacement to prevent infinite loops or unexpected behavior. Set the pattern to a meaningful search string.
Examples
Basic String Replacement
Replacing environment names in configuration... |
|
updates path for production: |
|
Case-Insensitive Replacement
Replacing text regardless of case... |
|
replaces all case variations: |
|
First Occurrence Only
Replacing only the first match... |
|
replaces first occurrence only: |
|
URL Path Modification
Updating API version in URLs... |
|
updates API version: |
|
Sensitive Data Masking
Replacing sensitive information with placeholders... |
|
masks sensitive values: |
|
Hostname Standardization
Standardizing hostname formats... |
|
updates all domain suffixes: |
|
Template Pattern Replacement
Using dynamic pattern from another field... |
|
replaces using field value as pattern: |
|
Empty Pattern Handling
Handling empty pattern gracefully... |
|
skips replacement with empty pattern: |
|