This works:
number=1
if [[ $number =~ [0-9] ]]
then
echo matched
fi
This does not work:
number=1
if [[ $number =~ "[0-9]" ]]
then
echo matched
fi
If we need to enclose regex into quotes, then should use a variable:
re="[0-9]"
if [[ $number =~ $re ]]; then echo MATCH; fi
|