imported>Xiplus
imported>Xiplus-abot
已保护“Module:String”:​高風險模板:2398431引用<!-- 機器人3 -->([编辑=仅允许管理员](无限期)[移动=仅允许管理员](无限期))
 
(未显示2个用户的4个中间版本)
第434行: 第434行:
if ignore_null_flag == nil then ignore_null_flag = false end
if ignore_null_flag == nil then ignore_null_flag = false end


mw.log(no_pattern_flag, ignore_null_flag);
length = mw.ustring.len(input_str)
length = mw.ustring.len(input_str)
--split函數起點
--split函數起點
第456行: 第455行:
end
end
if separ_str_end < separ_str_begin then separ_str_end = separ_str_begin end
if separ_str_end < separ_str_begin then separ_str_end = separ_str_begin end
mw.log(separ_str_begin, separ_str_end, iterator)
finded_str = mw.ustring.sub(input_str, iterator, separ_str_begin - 1)
finded_str = mw.ustring.sub(input_str, iterator, separ_str_begin - 1)
if not(mw.text.trim(finded_str) == '' and ignore_null_flag) then
if not(mw.text.trim(finded_str) == '' and ignore_null_flag) then
result[i] = finded_str
result[i] = finded_str
mw.log("\"" .. result[i] .. "\"")
i = i + 1
i = i + 1
end
end
第475行: 第472行:
end
end
return result;
return result;
end
--[[
join
Join all non empty arguments together; the first argument is the separator.
Usage:
{{#invoke:String|join|sep|one|two|three}}
]]
function str.join(frame)
local args = {}
local sep
for _, v in ipairs( frame.args ) do
if sep then
if v ~= '' then
table.insert(args, v)
end
else
sep = v
end
end
return table.concat( args, sep or '' )
end
end