lua-users home
lua-l archive

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


On Fri, Sep 9, 2011 at 4:38 PM, Francisco <xxleite@gmail.com> wrote:
> Awesome, i just replace with that code ...
>
> 22: for i, opt in ipairs(arg) do
> 23:    local token = opt:match("\\-+([a-z\\-]+)")
>
> and it worked! ...
> ill report to Zed Shaw ...

If opt are Lua strings and :match is the standard string.match,
perhaps what he meant, instead of \, was to use %, which is the escape
character for Lua patterns. However, since both "-" in the beginning
of a pattern and "-" in the end of a group carry no special meaning,
the correct code would probably be this:

 for i, opt in ipairs(arg) do
    local token = opt:match("-+([a-z-]+)")

Unless he means to match strings containing actual backslashes, then
the code would have to look like this:

 for i, opt in ipairs(arg) do
    local token = opt:match("\\%-+([a-z\\-]+)")

-- 
-- Hisham
http://hisham.hm/ - http://colorbleed.com.br/