I need an regex which will match following pattern a.b.c.d /nn
, for example 192.168.0.24 /32
.
Meanwhile I'd like to do some validations, so that in the octets the first number could be only 1 or 2, if the last 3 octets consist only 1 number it can be 0 too. In addition the numbers of octets should be up to 255. In the similar way for /nn, the first digit should be only from 1 to 3, but if it is 3, the second should be from 0 to 2, if the first is absence, then the only number should be from 1 to 9.
I could wrote pattern like this
(?<!\d)(?!0|4|5|6|7|8|9)\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3} +/(?<!\d)(?!0|4|5|6|7|8|9)\d{1,2}
but for example 192.168.740.056 /39
matches it as well.