regex – what is the correct map with regexp in nginx?

I want to use different builds depends of browser version and device.
For example in “mobile chrome/80+ version” I need to have modern-bundle and on lower versions – legacy-bundle. Bur modern version for desktop is lower than for mobile: “chrome/70+ version” must have modern-bundle and on lower than 70 – legacy-bundle

I tried this code with two maps but finally I always have legacy-bundle instead of modern-bundle
What’s wrong there?

map $http_user_request $is_mobile {
    default         false;
    "~*Mobile"      true;
}

map "$http_user_request:$is_mobile" $modern_browser {
    default     "";
    "~Chrome\/([8-9][0-9]|\d{3,})\.:true"       "modern-bundle";
    "~Chrome\/([7-9][0-9]|\d{3,})\.:false"      "modern-bundle";
}

Read more here: Source link