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:
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.