lua-users home
lua-l archive

Re: splitting string

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


On Mon, Aug 09, 2004 at 07:51:40AM +0000, Jacek Pop?awski wrote:
> What is simplest way to do it in Lua? In Python there is predefined function to
> split string, must I write one for Lua myself?
Yes. Try:
function split(str)
 local r = {}
 for m in string.gfind(str, "[^%s]+") do
 table.insert(r, m)
 end
 return r
end
-- Jamie Webb

AltStyle によって変換されたページ (->オリジナル) /