lua-users home
lua-l archive

[Date Prev][Date Next][Thread Prev][Thread Next] [Date Index] [Thread Index]


Sure, Thanks

2011/9/18 Duncan Cross <duncan.cross@gmail.com>
On Sun, Sep 18, 2011 at 8:05 AM, zhiguo zhao <zhaozg@gmail.com> wrote:
> print(string.find(uri,'/([%-%+])/(.-)/(.*)')) work OK.
> but i think "print(string.find(uri,'/([\-\+])/(.-)/(.*)'))" should not be
> wrong.

Even if Lua string-matching supported backslashes, they would have to
be double-backslashes not single-backslashes as you have here. In Lua
5.1, a string literal '...[\-\+]...' just becomes '...[-+]...' at the
compilation stage. This specific example actually happens to works
fine, because it turns out these characters don't need to be escaped
in this context: '-' has no special meaning when it is the first
character in a character set, and '+' has no special meaning inside a
character set at all.

-Duncan