lua-users home
lua-l archive

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


It is mentioned  in the manual:
"a single character class followed by '*', which matches 0 or more repetitions of characters in the class.
These repetition items will always match the longest possible sequence;"

I think the empty string after "abc" should not be matched in lua, just like in other  programmes (such as: sed,gawk) .
 
 
------------------ 原始邮件 ------------------
发送时间: 2009年12月27日(星期天) 下午3:20
收件人: "Lua list"<lua@bazar2.conectiva.com.br>;
主题: Re: A bug in pattern matching ??
 
On Sun, Dec 27, 2009 at 12:13 AM, goafteru <goafteru@qq.com> wrote:
>
> print ( string.gsub("abc", "%w*", "@") )
>
> and the result is:
> @@ 2
>
> rather than:
> @ 1

%w* can match the empty string, which it does after abc matches.


--
-Patrick Donnelly

"Let all men know thee, but no man know thee thoroughly: Men freely
ford that see the shallows."

- Benjamin Franklin