ngx_lua location capture issue

agentzh agentzh at
Thu Oct 20 11:48:29 UTC 2011

On Thu, Oct 20, 2011 at 6:48 PM, Nginx User <nginx at> wrote:
> Would the Nginx string literal you mentioned before not then turn
> "\\s" into "\s" ... which is were I want to be in the end? I suspect I
> am missing something in the process.

The Nginx config file parser first parses Nginx string literal


into Lua code"\\s")

and then Lua code parser parse the Lua string literal "\\s" into the
character string


which is the regex pattern that you want.

> Wish I could just use the familiar "\" and have it figured out in the
> background without me having to worry about it as rewrite apparently
> does though.

Nginx does have builtin support for regex syntax, so does Perl and
JavaScript, and that's why you do not have to esacpe "\" in that
context. Unfortunately Lua does not have such built-in regex syntax
support and the API was implemented by ngx_lua and by no means
to be a real a language extension to Lua.

As I said, try using external .lua file and
content/rewrite/access/set_by_lua_file to avoid nginx string escaping


More information about the nginx mailing list