[Date Prev][Date Next][Thread Prev][Thread Next]
[Date Index]
[Thread Index]
- Subject: RE: split method?
 
- From: Dave Collins <Dave.Collins@...>
 
- Date: Tue, 28 Jun 2011 10:44:32 -0400
 
Thanks Wesley, I'm going to use yours after all. Despite being a "black box", it does work.
Dave
>Wesley Smith:
>I think this function could be a lot simpler.  string.gmatch is more
>suited to this type of problem than string.find IMHO:
>
>local myDateString = "2011-06-21"
>
>function string:split(delim)
>	local res = {}
>	for v in self:gmatch(string.format("([^%s]+)%s?", delim, delim)) do
>		res[#res+1] = v
>	end
>	return res
>end
>
>local myDateTbl = myDateString.split(myDateString,"-")
>print(unpack(myDateTbl))