[Date Prev][Date Next][Thread Prev][Thread Next]
[Date Index]
[Thread Index]
- Subject: Re: string.gsub (Lua 5.1.1)
- From: "Leo Razoumov" <slonik.az@...>
- Date: Tue, 7 Nov 2006 11:40:10 -0500
On 11/7/06, Roberto Ierusalimschy <roberto@inf.puc-rio.br> wrote:
> Lua authors will decide if this is mis-description or mis-behavior :)
In this particular case, it seems simpler to declare the code right and
correct the manual. We have to clarify the manual anyway. The other
option (to really count "replacements") would need further clarification
of what counts as a "replacement".
-- Roberto
Thanks, Roberto!!
Counting matches instead of replacements IMHO is simpler to understand
and use. It also provides an easy way to count how many times a given
pattern occur in a string.
path= "/many/nested/directories"
_,n= path:gsub("/",{}) -- n counts "/" chars
--Leo--