<div dir="ltr"><div class="gmail_default" style="font-size:small;color:rgb(51,51,153)">Using named captures works (as demonstrated by <a href="https://stackoverflow.com/questions/12459518/nginx-extract-a-value-from-a-variable-or-any-string">https://stackoverflow.com/questions/12459518/nginx-extract-a-value-from-a-variable-or-any-string</a>), though:<br><div class="gmail_default" style="font-size:small;color:rgb(51,51,153)">map $host $foo {<br></div><div class="gmail_default" style="font-size:small;color:rgb(51,51,153)"> "~*^www\.(?<domain>.*)$" $domain; # Named capture wins<br></div><div class="gmail_default" style="font-size:small;color:rgb(51,51,153)"> default $foo;<br></div>}</div><div class="gmail_extra"><div><div class="gmail_signature"><font size="1"><span style="color:rgb(102,102,102)">---<br></span><b><span style="color:rgb(102,102,102)">B. R.</span></b><span style="color:rgb(102,102,102)"></span></font></div></div>
<br><div class="gmail_quote">On Mon, Nov 3, 2014 at 3:03 PM, B.R. <span dir="ltr"><<a href="mailto:reallfqq-nginx@yahoo.fr" target="_blank">reallfqq-nginx@yahoo.fr</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr"><div style="font-size:small;color:rgb(51,51,153)"><a href="http://nginx.org/en/docs/http/ngx_http_map_module.html#map" target="_blank">map's documentation</a> states:<br>A regular expression can contain named and positional captures
that can later be used in other directives along with the
resulting variable.<br><br></div><div style="font-size:small;color:rgb(51,51,153)">Trying to do the following failed validation:<br></div><div style="font-size:small;color:rgb(51,51,153)">map $host $foo {<br></div><div style="font-size:small;color:rgb(51,51,153)"> "~*^www\.(.*)$" $1; # Positional capture fails<br></div><div style="font-size:small;color:rgb(51,51,153)"> default $foo;<br></div><div style="font-size:small;color:rgb(51,51,153)">}<br><br></div><div style="font-size:small;color:rgb(51,51,153)">What am I doing wrong?<br clear="all"></div><div><div><font size="1"><span style="color:rgb(102,102,102)">---<br></span><b><span style="color:rgb(102,102,102)">B. R.</span></b><span style="color:rgb(102,102,102)"></span></font></div></div>
</div>
</blockquote></div><br></div></div>