Mikrotik script and regex

Hello there!

Probably i have a lot of problem with my knowledge, but here is my next question. I wanna use regular regular expression in my script, but i don’t understand why isn’t it work for me.

I used a few way them. First of all i don’t escaped the dot so it was something like this:

address~“^(10.100.[1-9]{1,3}.[023456789]{1,3})$”

but its so far from where i need to be, so i ask for help, than i got this solution:

address~^(10[.]100[.][1-9]{1,3}.{1,3})

Here i got errors for ? and for the \d , so they need to be escaped, but how? divine spark with double \ .
Sooo

address~“10\.100\.([1-9]\d*|\d{2,})\.([^1]$|\d{2,})$”

But in this case give me back a null value as variable, but like in this https://regex101.com/r/X6gdmW/1 site, probably it’s must to work isn’t it?

I hope someone will know what is the problem with it. Thx

https://wiki.mikrotik.com/wiki/Manual:Regular_Expressions

https://pubs.opengroup.org/onlinepubs/9699919799/basedefs/V1_chap09.html

address~“^(10.100.[1-9]{1,3}.[023456789]{1,3})$”
=>
address~“^10.100.[1-9]{1,3}.[02-9]{1,3}$”

\d => [0-9]

address~“^(10.100.[1-9]{1,3}.[023456789]{1,3})$”
=>
address~“^10.100.[1-9]{1,3}.[023456789]{1,3}$”

But, if i use only one backslash than it got an error.

Probably i used this code now:

if ([:len [/ip address find where address~“10.100.”]] > 0)
do={:put “1”;
if ([:len [/ip address find where address~“^(10\.100\.([1-9]|\d{2,3})\.([02-9]|\d{2,}))$”]]>0)
do={:put “2”;:local var [/ip address find address~“^(10\.100\.[1-9]{1,3}\.(?:[02-9]|\d{2,3})$)”]; :put $var}}

Its just a test function, but in the end i want to use it in a lot of different router. But now i have this ip addresses in the test router:
10.100.0.4/24
10.100.1.11/24
10.100.44.1/24
The rules:
In the 3rd octet can’t be a single 0, but it can be 10 or 100 etc.
and in the 4rd octet cant be a single 1 like in the 3rd example.
I need to search ip address with this 2 rules. So in the solution i need to save in a variable the ip address like 10.100.1.11(/24) and i want to use it later.
The first if statement is true so it give back the “1” but in the 2nd if statement gives back a null value.

On terminal you mus “manually” escape… the escape,

\ => \

address~“^10\.100\.[1-9]{1,3}\.[02-9]{1,3}$”

also with \ before $

$ = $
\d => [0-9]

? must be escaped on terminal: ?

\d => [0-9]

? must be escaped on terminal: ?

So mikrotik script doesn’t operate with \d so i need to use [0-9] ?

better put [0-9] than count everytime how many \ you put on testing purpose or in saved script…