Subdomain server_name help

i want to send all requests with a subdomain that contains a particular
string to be sent to a particular backend.

for ex analyzerAA.XX.com and BBanalyzer.XX.com should be selected.

what is the correct way of writing this configuration?
thanks a lot

server {
    server_name  analyzer.XX.com;
    location / {
        fastcgi_pass backend_analyzer;
    }
}