2

The HttpMapModule documentation states that:

Since 1.0.4, case insensitive regular expressions can be used by prefixing the pattern with ~*.

And gives the example:

map $uri $myvalue {
    /aa                   /mapped_aa;
    ~^/aa/(?<suffix>.*)$  $suffix;
}

I updated to nginx/1.2.7 to make use of this, and naive regexes work okay, but variables don't. When I try the above syntax I get the error:

nginx: [emerg] pcre_compile() failed: unrecognized character after (?< in "^/aa/(?<suffix>.*)$" at "suffix>.*)$"

I also tried the following syntaxes, but none of them worked:

~^(.*)$  $1;
~^(.*)$  \1;

but neither of them worked either.

Does anyone know how to get variables to work in regular expressions in HttpMapModule?

Robin Winslow
  • 209
  • 1
  • 3
  • 11

1 Answers1

9

(?P<name>pattern) is the standard PCRE syntax for named capture-groups - the documentation is missing a P.

The "Named Subpatterns" section on Wikipedia states that (?<name>...) and (?'name'...) are valid for PCRE 7.0 onwards; presumably your version of nginx is linked against an earlier version of PCRE.

nickgrim
  • 4,336
  • 1
  • 17
  • 27