String Replace
Replaces all occurrences of a substring or regex pattern within a string.
Replaces all occurrences of a target string or pattern within an input string.
Operation Modes#
The node has two modes, controlled by the op input:
- String: Performs a literal, case-sensitive replacement of the
substringtext. - Regex: Treats the
substringinput as a regular expression pattern to find matches.
Regex Details#
When using Regex mode:
- The pattern syntax is based on Go's RE2 engine.
- You can reference capture groups from your pattern in the replacement string using $ notation.
- Example: $1 for the first group, $2 for the second, and ${name} for a named group.
Example#
- input:
"The year is 2024." - op:
Regex - substring:
(\d{4}) - replacement:
2077 - result:
"The year is 2077."
Inputs#
| Port | Description |
|---|---|
| The original string to process. | |
| The replacement method to use. | |
| The text or regular expression pattern to find. | |
| The text that replaces found occurrences. |
Outputs#
| Port | Description |
|---|---|
| The resulting string after replacements. |
ID: core/string-replace@v1