In bash script, /d
fails while same worked with [0-9]
ip="106.990.120.78"
regex1="^(\d+\.){3}\d+$"
regex2="^([0-9]+\.){3}[0-9]+$"
if [[ $ip =~ $regex2 ]]; then
echo "success"
else
echo "fail"
fi
Both patterns work same in https://regex101.com/r/cNhDAL/1
/d also used for numeric that are in string. Why such behavior in bash shell?
Note: I am just matching the pattern only, not checking either IP is valid or not