词条 | Module:Sandbox/Ederporto/Test |
释义 | -- Module test for splitting strings by some substring parsed local p = {} function p.split(frame) local text = frame.args.text or frame.args[1] local sep = frame.args.sep or frame.args[2] local nreturn = tonumber(frame.args.nreturn) or tonumber(frame.args[3]) local out = {} local count = 1
local from = 1 local sep_from, sep_to = string.find(text, sep, from) while sep_from do if count == nreturn then return string.sub(text, from, sep_from-1) end from = sep_to+1 sep_from, sep_to = string.find(text, sep, from) count = count + 1 end if count == nreturn then return string.sub(text, from) end end return p |
随便看 |
|
开放百科全书收录14589846条英语、德语、日语等多语种百科知识,基本涵盖了大多数领域的百科知识,是一部内容自由、开放的电子版国际百科全书。