Variable interpolation in a regex

Hello All,

I have a map block:

    map $http_cookie $myVal {
            "~adq_cnv(\d+)=($cmpid[^;]+#(?P<DC>\w{2}))(?:;|$)" $DC;
            default "XYZ";
    }

The $cmpid used in the left side of a map is to be interpolated from a
location block :

   location ~ ^/cnv/(\d+)/ {
             set $cmpid  $1;
              ...
   }

But that is not working. I tried different variations like : ${cmpid},
$cmpid . But to no luck.

Any help would be appreciated.

Thanks
Harish

On Tuesday 04 September 2012 23:55:07 Harish S. wrote:

Hello All,

I have a map block:

    map $http_cookie $myVal {
            "~adq_cnv(\d+)=($cmpid[^;]+#(?P<DC>\w{2}))(?:;|$)" $DC;
            default "XYZ";
    }

[…]

But that is not working. I tried different variations like : ${cmpid},
$cmpid . But to no luck.

Any help would be appreciated.

Regular expressions in config file are compiled at the configuration
phase, so
you can’t use variables there.

wbr, Valentin V. Bartenev

Hi Valentin,
Thanks. Is there any way to achieve the same thing through some other
means, even if it takes a hit on the performance ?

Thanks
Harish