I have this regex, to match version numbers:
^[1-9]\d{0,1}\.(?!0\d)\d{1,3}\.(?!0\d)\d{1,4}$
Regex itself works and matches "1.0.0" when checked on RegexChecker However, when I try to wrap same regex in a bash script, my code goes in "else" condition. I fail to understand why ?
#!/bin/bash
VERSION='1.0.0'
MATCH_PATTERN='^[1-9]\d{0,1}\.(?!0\d)\d{1,3}\.(?!0\d)\d{1,4}$'
if [[ $VERSION =~ $MATCH_PATTERN ]]; then
:
else
echo "Version number format is wrong."
exit 1
fi
I tried running with debugger using set -x
but no luck. Any suggestions ?