From 10a6d7c29435f70702174ce8f5c68cc924d5c434 Mon Sep 17 00:00:00 2001 From: Victor Moene Date: Mon, 6 Jul 2026 14:03:30 +0200 Subject: [PATCH] Updated docs for string_replace Ticket: CFE-4694 Signed-off-by: Victor Moene --- content/reference/functions/string_replace.markdown | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/content/reference/functions/string_replace.markdown b/content/reference/functions/string_replace.markdown index 07c50e8e7..1980802d7 100644 --- a/content/reference/functions/string_replace.markdown +++ b/content/reference/functions/string_replace.markdown @@ -5,15 +5,16 @@ aliases: - "/reference-functions-string_replace.html" --- -{{< CFEngine_function_prototype(string, match, replacement) >}} +{{< CFEngine_function_prototype(string, match, replacement, option) >}} -**Description:** In a given string, replaces a substring with another string. - -{{< CFEngine_function_attributes(string, match, replacement) >}} +**Description:** Replaces a substring, or a list of substrings, within a given string with a specified replacement string or list of replacement strings. +{{< CFEngine_function_attributes(string, match, replacement, option) >}} Reads a string from left to right, replacing the occurences of the second argument with the third argument in order. +By default, the `option` parameter is set to `"strings"`, meaning the function expects `match` and `replacement` to be single strings. To use lists of strings instead, set option to `"lists"`. Lists can be passed as variables or inline JSON. However, their lengths must match exactly, as substitutions are applied pairwise. Note that mixing single string and list arguments is not supported. + All characters in the string to replace in, the substring to match for and the replacement are read literally. This means that `.`, `*`, `\` and similar characters will be read and replaced as they are. If you are looking for more