lua-users home
lua-l archive

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


On Wed, Aug 12, 2015 at 9:37 PM, Parke <[email protected]> wrote:
>> Dirk Laurie <[email protected]> writes:
>> > Give an example of a source/pattern combination such that
>> > source:match(pat) matches but source:gmatch(pat) fails to
>> > find a match.

> On Wed, Aug 12, 2015 at 4:00 PM, Michael Welsh Duggan <[email protected]> wrote:
>> string: "a"
>> pattern: "^a"

On Wed, Aug 12, 2015 at 12:30 PM, Pierre-Yves Gérardy <[email protected]> wrote:
> Crikey, that's a strung.lua bug!

While I personally find this behavior surprising, if it is a bug, it
is a documented and intentional one.

http://www.lua.org/manual/5.3/manual.html#pdf-string.gsub

"For this function, a caret '^' at the start of a pattern does not
work as an anchor, as this would prevent the iteration."

Yes, it works as advertised, but I overlooked it in my port[0].

​Pierre-Yves​