From fc2547c13764de7ea485da12f4bf2a3610bd7a28 Mon Sep 17 00:00:00 2001 From: Christian Hesse Date: Fri, 8 Feb 2019 12:54:54 +0100 Subject: global-functions: add $CharacterReplace --- global-functions | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/global-functions b/global-functions index 8b7c5b3..50d0eed 100644 --- a/global-functions +++ b/global-functions @@ -40,6 +40,21 @@ :return $Return; } +# character replace +:global CharacterReplace do={ + :local String [ :tostr $1 ]; + :local ReplaceFrom [ :tostr $2 ]; + :local ReplaceWith [ :tostr $3 ]; + :local Len [ :len $ReplaceFrom ]; + + :while ($String ~ $ReplaceFrom) do={ + :local Pos [ :find $String $ReplaceFrom ]; + :set String ([ :pick $String 0 $Pos ] . $ReplaceWith . [ :pick $String ($Pos + $Len) 999 ]); + } + + :return $String; +} + # check and import required certificates :global CertificateAvailable do={ :local CommonName [ :tostr $1 ]; -- cgit v1.2.3-54-g00ecf