Forum: NGINX Problem with {} in map regex matching

526b09f2b949aae346eda86df5827b1f?d=identicon&s=25 "António P. P. Almeida" <appa@perusio.net> (Guest)
on 2013-10-09 13:05
(Received via mailing list)
To my surprise, apparently doing a match with {} like in:

 map $args $has_tr0_arg {
        default 0;

~"tr%5B0%5D%3D=[1-9][[:digit:]]{3}-[[:digit:]]{2}-[[:digit:]]{2}T[[:digit:]]{2}%2F[1-9][[:digit:]]{3}-[[:digit:]]{2}-[[:digit:]]{2}T[[:digit:]]{2}%26"
1;

~"%26tr%5B0%5D%3D=[1-9][[:digit:]]{3}-[[:digit:]]{2}-[[:digit:]]{2}T[[:digit:]]{2}%2F[1-9][[:digit:]]{3}-[[:digit:]]{2}-[[:digit:]]{2}T[[:digit:]]{2}"
1;
 }

Doesn't work.

Which is bit surprising knowing that location regex matching works with
{},
of course you have to quote it, like I do above.

This is what I get from nginx -t:

 nginx: [emerg] unexpected "{" in /etc/nginx/nginx.conf

Is this expected behavior or I'm doing something wrong here?


Thanks,
----appa
A8108a0961c6087c43cda32c8616dcba?d=identicon&s=25 Maxim Dounin (Guest)
on 2013-10-09 13:45
(Received via mailing list)
Hello!

On Wed, Oct 09, 2013 at 01:04:46PM +0200, António P. P. Almeida wrote:

>  }
> Is this expected behavior or I'm doing something wrong here?
Leading '~' is outside quotes, which results in your regular
expression being interpreted as non-quoted string.  Use something
like this instead:

    map ... {
        "~(foo){3}" 1;
    }

--
Maxim Dounin
http://nginx.org/en/donation.html
Please log in before posting. Registration is free and takes only a minute.
Existing account

NEW: Do you have a Google/GoogleMail, Yahoo or Facebook account? No registration required!
Log in with Google account | Log in with Yahoo account | Log in with Facebook account
No account? Register here.