I'm trying to write a simple regex in a shell script and I can't get it to match anything. I'm not sure if my regex is incorrect or my shell code is incorrect
#!/bin/sh
#
# This hook verifies that the commit message contains a reference to a tfs item
# Regex to validate a string contains "#" and 4 or 5 digits
regex="/#\d{4,5}/"
param=$1
echo "param = $param"
echo "regex = $regex"
if [[ $param =~ $regex ]]; then
output="yes"
else
output="no"
fi
echo "output = $output"
...
I'm running my script with $ ./myscript "#1234" and $ ./myscript "asdf #1234 asdf" and those should both output "yes"