For reference, however this is already mentioned in this answer, from man bash
Pattern Matching section provide rules for composite pattern creation as:
Composite patterns may be formed using one or more of the following sub-patterns:
?(pattern-list)
Matches zero or one occurrence of the given patterns.
*(pattern-list)
Matches zero or more occurrences of the given patterns.
+(pattern-list)
Matches one or more occurrences of the given patterns.
@(pattern-list)
Matches one of the given patterns.
!(pattern-list)
Matches anything except one of the given patterns.
However using these extended pattern matching require extglob
shell option to be enabled.
Here is example of code for current problem:
shopt -s extglob;
SERVER="ws-45454.host.com";
case $SERVER in
ws-+([0-9])\.host\.com) echo "Web Server"
;;
db-+([0-9])\.host\.com) echo "DB server"
;;
bk-+([0-9])\.host\.com) echo "Backup server"
;;
*)echo "Unknown server"
;;
esac;
shopt -u extglob;
also, this: shopt | grep extglob
can be used to check for its default value.