Regex positional capture in map

Igor Sysoev igor at sysoev.ru
Mon Nov 3 14:22:29 UTC 2014


On 03 Nov 2014, at 17:18, B.R. <reallfqq-nginx at yahoo.fr> wrote:

> Using named captures works (as demonstrated by https://stackoverflow.com/questions/12459518/nginx-extract-a-value-from-a-variable-or-any-string), though:
> map $host $foo {
>     "~*^www\.(?<domain>.*)$"    $domain; # Named capture wins
>     default                    $foo;
> }

default  $host;

-- 
Igor Sysoev
http://nginx.com

> On Mon, Nov 3, 2014 at 3:03 PM, B.R. <reallfqq-nginx at yahoo.fr> wrote:
> map's documentation states:
> A regular expression can contain named and positional captures that can later be used in other directives along with the resulting variable.
> 
> Trying to do the following failed validation:
> map $host $foo {
>     "~*^www\.(.*)$"    $1; # Positional capture fails
>     default                    $foo;
> }
> 
> What am I doing wrong?
> ---
> B. R.

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mailman.nginx.org/pipermail/nginx/attachments/20141103/490a553d/attachment.html>


More information about the nginx mailing list