aboutsummaryrefslogtreecommitdiffstats
path: root/global-functions
diff options
context:
space:
mode:
authorGravatar Christian Hesse <mail@eworm.de>2019-02-08 12:54:54 +0100
committerGravatar Christian Hesse <mail@eworm.de>2019-02-08 12:54:54 +0100
commitfc2547c13764de7ea485da12f4bf2a3610bd7a28 (patch)
treedc02e583ff3183337e9c9f70cadc1808bddcb364 /global-functions
parent4c618494837bb6df1e95cbdfe6d2672aea3fecd4 (diff)
global-functions: add $CharacterReplace
Diffstat (limited to 'global-functions')
-rw-r--r--global-functions15
1 files changed, 15 insertions, 0 deletions
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 ];