I simply need to know how to make a regex that accepts a number that has up to 2 digits
All I have just now is
^[0-9]{2}$
Which would match a number with exactly 2 digits, but I don't know how to specify "match a number which has up to 2 digits".
Also, if there is a way to make sure that this number isn't 0 then that would be a plus, otherwise I can check that with Bash.
Thanks ! :)
Note that the input variable comes from read -p "make a choice" Number
EDITING MY POST - SHOWING CODE IN CONTEXT :
while true; do
read -p "Please key in the number of the engineer of your choice, or leave empty to select them all: " Engineer
if [ -z "$Engineer" ]; then
echo "No particular user specified, all engineers will be selected."
UserIdSqlString="Transactions.Creator!=0 "
break
else
if [[ $Engineer =~ ^[0-9]{1,2}$ && $Engineer -ne 0 ]]; then
echo "If you want a specific engineer type their number otherwise leave blank"
else
echo "yes"
break
fi
fi
done
grep
orsed
or something? – Guesthouseif-else
backward.if [[ $Engineer =~ ^[0-9]{1,2}$ && $Engineer -ne 0 ]];
returns true when you have a non-zero two digit number set intoEngineer
soecho "yes"
should follow this – ComplianceEngineer
's value is08
or09
. Please see my comment in 1_CR's answer below. – Sosanna