I am trying to match a string with a regex in a shell script. This string is a parameter of the script ( $1 ) and it is a date (MM/DD/YYYY) The regex I\'m trying to use is :
I think this is what you want:
REGEX_DATE='^\d{2}[/-]\d{2}[/-]\d{4}$' echo "$1" | grep -P -q $REGEX_DATE echo $?
I've used the -P switch to get perl regex.