I’m using the same format as in your second example to accomplish the same that you want to do. And I think \d represents a digit and \d+ one or more digits… but i’m not an expert
To test regular expressions below use “grep -e” from the command line. If you see the hostname echo’ed the regex worked.
For example:
echo ‘mailanything.123.somedomain.com’ | grep -e ‘^mail\S*.somedomain.com$’