ngx_lua location capture issue

agentzh agentzh at gmail.com
Thu Oct 20 08:46:14 UTC 2011


On Thu, Oct 20, 2011 at 4:17 PM, Nginx User <nginx at nginxuser.net> wrote:
>> Why not put your Lua code into an external .lua file and use
>> access_by_lua_file or rewrite_by_lua_file instead? That way you only
>> need to escape each "\" only once.
> I am using an external .lua file and I only get consistent results
> when I use "\\\s" etc. "\\s" etc resulted is several ")" expected near
> "|" type messages.
>

"\\\s" is essentially equivalent to "\\s" in Lua string literals
because "\s" evaluates to "s".

You can try small examples on your shell (ensure you have the "lua"
interpreter visible in your PATH environment):

    $ lua -e 'print("\s" == "s")'
    true

    $ lua -e 'print("\\\s" == "\\s")'
    true

    $ lua -e 'print("\\s")'
    \s

    $ lua -e 'print("\\\s")'
    \s

> Basically, it's what seems to work for me.
>

I suggest you design trivial samples like above to get clear what is
going on here :)

Regards,
-agentzh



More information about the nginx mailing list