lua-users home
lua-l archive

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

> > Lua 5.3.3  Copyright (C) 1994-2016, PUC-Rio
> > > =(";a;"):gsub("a-", "ITEM")
> > 
> > I.e. the substring 'a' in ";a;" is not recognized as an instance
> > of the pattern "a-".
> The substring 'a' is not an instance of the pattern "a-", given that
> '' is also valid and shorter than 'a'. So, this behavior seems correct.

Complementing my answer: the issue (and the "Python rule") is about
*where* things match, not *how* they match.

The behavior is like that ('|' is the current position):

  '|a' x 'a-'   -> matches the empty string -> OK.
  '|a' x 'a-'   -> matches the empty string, but ending at the same position
                   of previous match -> fail.
  'a|' x 'a-'   -> goes to next character to try a match.

-- Roberto