I'm very new to Bash. Can someone tell me what am I doing wrong. I tried the following regex pattern online and it works fine. But Bash script below refuses to match.
I need to extract the value of status: from the last line of a text block like so:
res=$(cat <<-EOM
Conducting pre-submission checks for my.zip and initiating connection to the Apple notary service...
Submission ID received
  id: 573ebf8c-5434-4820-86c6-46adf01f81a9
Successfully uploaded file
  id: 573ebf8c-5434-4820-86c6-46adf01f81a9
  path: path-to.zip
Waiting for processing to complete.
Current status: Invalid.....Processing complete
  id: 573ebf8c-5434-4820-86c6-46adf01f81a9
  status: Invalid
EOM
)
# Get status -- need word "invalid" from this line:  status: Invalid
status=""
regex='status:\s*(\w+)$'
[[ $res =~ $regex ]] &&
  status=${BASH_REMATCH[1]}
echo "stat=$status"
 
     the
 the 