Mòdul:StringFunc: diferència entre les revisions
Contingut suprimit Contingut afegit
Cap resum de modificació |
Cap resum de modificació |
||
Línia 45:
source: The string to return a subset of
separator: The string to split on
count: The nth substring based on the
]]
function p.split( frame )
local new_args = p._getParameters( frame.args, {'source', '
local source_str = new_args['source'] or '';
local
local
if source_str == '' or
return source_str;
end
local l_plain = p._getBoolean( new_args['plain'] or true );
local ret_count = tonumber( new_args['count'] ) or 1;
if ret_count < 1 then
return "";
end
local start = 1;
local iter = mw.ustring.find(source_str,
if iter == nil then
if ret_count == 1 then
Linha 75 ⟶ 78:
for i=2, ret_count do
start = iter+pattern_len + 1;
iter = mw.ustring.find(source_str,
if iter == nil then
if ret_count == i then
|