Basic Bash Regex

Basic regex operator is =~ with basic syntax

1[[ "string" =~ pattern ]]

NOTE pattern is not quoted, only the string.

Very basic example when checking if a variable has either values 'running' or 'exited':

1status='running' ##  change to 'exited' and '' to see it works
2if [[ "$status" =~ running|exited ]]; then
3    echo "Is either running or exited"
4else
5    echo "Nope, I don't understand that status"
6fi

See stackoverflow post