Welcome! Log In Create A New Profile

Advanced

Re: PCRE named captures sill counted in numerical variables list

Maxim Dounin
April 03, 2014 09:22AM
Hello!

On Thu, Apr 03, 2014 at 03:08:14PM +0200, B.R. wrote:

> I tried to configure the following location with something like:
>
> location ~*
> "^/([[:alpha:]]{1,8}(?<subtag>-[[:alpha:]]{1,8})?)(/.*[^/])?/?$" {
> try_files $uri $uri/ $2/?lang=$1&$args;
> }
>
> ​However, the $2 variable does not catch the last part of the URI as
> expected (either it catches the named capture or nothing at all, that I do
> not know nor care).​
>
> ​Using $3 instead of $2 does the job.​
>
>
> ​I thought that using named captures allowed for those capture not to be
> counted in numerical variable​
> ​.
>
> ​
> ​Am I wrong expecting that?

Yes, you are wrong, "man perlre" says:

Named groups count in absolute and relative
numbering, and so can also be referred to by those numbers.

The same does "man pcrepattern":

Named capturing parentheses are still allocated numbers
as well as names, exactly as if the names were not present.

From pattern point of view, it's just an human-friendly alias for
a capture.

--
Maxim Dounin
http://nginx.org/

_______________________________________________
nginx mailing list
nginx@nginx.org
http://mailman.nginx.org/mailman/listinfo/nginx
Subject Author Posted

PCRE named captures sill counted in numerical variables list

B.R. April 03, 2014 09:10AM

Re: PCRE named captures sill counted in numerical variables list

Maxim Dounin April 03, 2014 09:22AM

Re: PCRE named captures sill counted in numerical variables list

B.R. April 03, 2014 09:44AM



Sorry, only registered users may post in this forum.

Click here to login

Online Users

Guests: 219
Record Number of Users: 8 on April 13, 2023
Record Number of Guests: 421 on December 02, 2018
Powered by nginx      Powered by FreeBSD      PHP Powered      Powered by MariaDB      ipv6 ready