[Date Prev][Date Next][Thread Prev][Thread Next]
[Date Index]
[Thread Index]
- Subject: Re: maybe a regex bugs in luajit2
- From: Duncan Cross <duncan.cross@...>
- Date: Sun, 18 Sep 2011 10:12:37 +0100
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