RegEx is not matching
by blason from LinuxQuestions.org on (#57BE7)
Hi there,
Can someone please help me on regex pattern matching with my below function?
This is matching IPv4 addresses but somehow my IPv6 addresses are not getting matched
Code:212.129.46.32
213.163.64.208
217.61.0.97
223.5.5.5
223.6.6.6
2001:1398:1:0:200:1:123:46
2001:19f0:5:6012:5400:2ff:fe60:7579
2001:19f0:5801:b7c::1
2001:19f0:6401:b3d:5400:2ff:fe5a:fb9fCode:function convert {
while read ip; do
if ! [[ "$ip" =~ [^0-9.-] ]];
then
todo[$y]+=" $ip $ip"
if [ $z -eq 2000 ]
then
z=0
let y=$y+1
else
let z=$z+1
fi
fi
done
dynamic_objects -do ti_$type
dynamic_objects -n ti_$type
for i in "${todo[@]}" ;
do
dynamic_objects -o ti_$type -r $i -a
done
}


Can someone please help me on regex pattern matching with my below function?
This is matching IPv4 addresses but somehow my IPv6 addresses are not getting matched
Code:212.129.46.32
213.163.64.208
217.61.0.97
223.5.5.5
223.6.6.6
2001:1398:1:0:200:1:123:46
2001:19f0:5:6012:5400:2ff:fe60:7579
2001:19f0:5801:b7c::1
2001:19f0:6401:b3d:5400:2ff:fe5a:fb9fCode:function convert {
while read ip; do
if ! [[ "$ip" =~ [^0-9.-] ]];
then
todo[$y]+=" $ip $ip"
if [ $z -eq 2000 ]
then
z=0
let y=$y+1
else
let z=$z+1
fi
fi
done
dynamic_objects -do ti_$type
dynamic_objects -n ti_$type
for i in "${todo[@]}" ;
do
dynamic_objects -o ti_$type -r $i -a
done
}