I was trying to create a regex that match a ip adress, or a ip adress with netmask: something like 8.8.8.8/24
if ! [[ $SOURCE =~ ^[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}$ ]] || [[ $SOURCE =~ ^[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\/[0-9]{1,2}$ ]];then
echo ERROR: Invalid Source
exit 1
fi
The first part matchted well, the second, with the netmask doest match.. Anyone know why?