I'm trying to check if a string matches this format:
10_06_13
i.e. todays date, or a similar date with "2digits_2digits_2digits".
What I've done:
regex='([0-9][0-9][_][0-9][0-9][_][0-9][0-9])'
if [[ "$incoming_string" =~ $regex ]]
then
# Do awesome stuff here
fi
This works to a certain extent. But when the incoming string equals 011_100_131
, it still passes the regex check. How can I fix my regex to only accept the right format?
_
matches the same thing as[_]
. – Colson