i have a CIDR range in this regex
^5\.188\.62\.([1-9]?\d|[12]\d\d)$
I am able to confirm matching values using https://regexr.com
Now i am testing some code and i am using the following as a sample to test matches
var='^5\.188\.62\.111';[[ $var =~ '^5\.188\.62\.([1-9]?\d|[12]\d\d)$' ]] && echo yes || echo no
In final, i am not able to get it working.
Any tip to solve?
Thanks
var=5.188.62.212
? – Eduardo Trápani Jun 26 '20 at 15:07=~
, don't quote the thing on the right – Andy Dalton Jun 26 '20 at 15:08\d
is a PCRE element – steeldriver Jun 26 '20 at 15:11[[ $var =~ '^5\.188\.62\.([1-9]?\d|[12]\d\d)$' ]]
would be OK (and would match onvar=5.188.62.111
) inzsh
instead ofbash
afterset -o rematchpcre
. – Stéphane Chazelas Jun 26 '20 at 15:25