PCRE with NGINX

Hi,

I am trying to insert a PCRE inside a map block. But looks like “{” used
in
my code is not liked.

Suppose I am doing something like this inside a “map” block.

.{1}(?P<string>.{9}).*

What is the escape character for "{ "

Please let me know.

Thanks…

Posted at Nginx Forum:

{
Would do it.

Posted at Nginx Forum:

I tried that alrwady . I don’t get errors. But, the functionality does
not
work. So, I am not sure if the PCRE is not liking it or something
else…Still debugging.

Posted at Nginx Forum:

This works:
~{.:; 1;
with map, do note that a 400 in logging means something else which
precedes
map handling.

Posted at Nginx Forum:

Thanks for the explanation.
Sorry, not able to understand you fully.
My PCRE is something like this (have tested it through
https://regex101.com/)

.+..{3}(?P.{6})[^.]*$

Now, to achieve this what should I put in the nginx.conf

Please let me know.

Posted at Nginx Forum:

I looked @ Server names
It sames put it inside " " and once I did that it is working
Thank you.

Posted at Nginx Forum:

On Tue, May 05, 2015 at 04:50:28AM -0400, nginxsantos wrote:

Hi there,

I looked @ Server names
It sames put it inside " " and once I did that it is working

Yes - “wrap the regex in double quotes” is the right answer.

This line does appear in the documentation for “rewrite” and for “if”;
but not for “location” or “map”.

nginx documentation improvement suggestion:

It may be worth adding it to those (and anywhere else that uses
regexes);
or to link from everywhere to a “regex in nginx” document.

(Yes, I know “patches welcome”, and I’m not providing any. I’m not sure
whether “duplicate” or “link” is better.)

Thanks,

f

Francis D. [email protected]