In Bash I'm trying to check if a string is in the appropriate format.
#!/bin/bash
COMMIT_MSG="release/patch/JIRA-123"
[[ $COMMIT_MSG =~ 'release\/(major|minor|patch)\/[A-Z\d]+-\d+' ]] && echo "yes" || echo "no"
This is the regex I've used to match the string as patch could be either major or minor and JIRA-123 is Jira Ticket ID but when trying it in the Bash regex it always returns no.
[[ $COMMIT_MSG =~ release/(major|minor|patch)/[A-Z0-9]+-[0-9]+ ]]. Don't quote the regex and use0-9instead of\d.\dprobably isn't supported (especially inside a bracket expression).condition && action1 || action2in bash is not a ternary expression so be careful when treating it as one - as written you could getnooutput even if your regexp comparison succeeded. Whether or not you care probably depends on how likely you think it is thatecho "yes"might fail.