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 <parke.nexus@gmail.com> wrote:
>> Dirk Laurie <dirk.laurie@gmail.com> 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 <mwd@cert.org> wrote:
>> string: "a"
>> pattern: "^a"

On Wed, Aug 12, 2015 at 12:30 PM, Pierre-Yves Gérardy <pygy79@gmail.com> 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​