lua-users home
lua-l archive

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

The Manual states:

string.gsub (s, pattern, repl [, n])

Returns a copy of s in which all occurrences of the
pattern have been replaced by a replacement string
specified by repl, which may be a string, a table, or a
function. gsub also returns, as its second value, the
total number of substitutions made.
If the value returned by the table query or by the
function call is a string or a number, then it is used as
the replacement string; otherwise, if it is false or nil,
then there is no replacement (that is, the original match
is kept in the string).

So each of the following calls

  string.gsub("a", "a", function() end)
  string.gsub("a", "a", {})

should return "a", 0

However each of them returns "a", 1