lua-users home
lua-l archive

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

Luiz Henrique de Figueiredo writes:
> > ...
> > local n = select(2, s:gsub("[^\n]*\n[^\n]*", ""))
> Or this:
> 	local _,n = s:gsub('.-\n', '')

May be less memory efficient but terser:

      return # s:gsub("[^\n]", "")

The general form can answer queries such as, "How many characters in a given set
are in a string?"