mirror of
https://github.com/nymurbd/MikroTik-scripts.git
synced 2025-07-27 22:34:36 +02:00
global-functions: introduce $EscapeForRegEx
This commit is contained in:
parent
baa096fe03
commit
7c4ab95394
1 changed files with 23 additions and 0 deletions
|
@ -24,6 +24,7 @@
|
||||||
:global DeviceInfo;
|
:global DeviceInfo;
|
||||||
:global DNSIsResolving;
|
:global DNSIsResolving;
|
||||||
:global DownloadPackage;
|
:global DownloadPackage;
|
||||||
|
:global EscapeForRegEx;
|
||||||
:global FlushEmailQueue;
|
:global FlushEmailQueue;
|
||||||
:global FlushTelegramQueue;
|
:global FlushTelegramQueue;
|
||||||
:global GetMacVendor;
|
:global GetMacVendor;
|
||||||
|
@ -289,6 +290,28 @@
|
||||||
:return false;
|
:return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
# escape for regular expression
|
||||||
|
:set EscapeForRegEx do={
|
||||||
|
:local Input [ :tostr $1 ];
|
||||||
|
|
||||||
|
:if ([ :len $Input ] = 0) do={
|
||||||
|
:return "";
|
||||||
|
}
|
||||||
|
|
||||||
|
:local Return "";
|
||||||
|
:local Chars "^.[]\$()|*+\?{}\\";
|
||||||
|
|
||||||
|
:for I from=0 to=([ :len $Input ] - 1) do={
|
||||||
|
:local Char [ :pick $Input $I ];
|
||||||
|
:if ([ :find $Chars $Char ]) do={
|
||||||
|
:set Char ("\\" . $Char);
|
||||||
|
}
|
||||||
|
:set Return ($Return . $Char);
|
||||||
|
}
|
||||||
|
|
||||||
|
:return $Return;
|
||||||
|
}
|
||||||
|
|
||||||
# flush e-mail queue
|
# flush e-mail queue
|
||||||
:set FlushEmailQueue do={
|
:set FlushEmailQueue do={
|
||||||
:global EmailQueue;
|
:global EmailQueue;
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue