打开/关闭菜单
切换首选项菜单
打开/关闭个人菜单
未登录
未登录用户的IP地址会在进行任意编辑后公开展示。

模块:StringUtil:修订间差异

来自此界与彼端
无编辑摘要
无编辑摘要
 
第7行: 第7行:


function p.split(str, separator)
function p.split(str, separator)
mw.log(str)
if str == nil then
mw.log(separator)
return {}
end
     local fields = {}
     local fields = {}
     local temp = str:gsub(", ", ",")
     local temp = str:gsub(", ", ",")

2025年4月2日 (三) 16:43的最新版本

此模块的文档可以在模块:StringUtil/doc创建

local p = {}

function p.replace(str, target, result)
	local res = str:gsub(target, result)
	return res
end

function p.split(str, separator)
	if str == nil then
		return {}
	end
    local fields = {}
    local temp = str:gsub(", ", ",")
    temp:gsub("[^"..separator.."]+", function(c) fields[#fields + 1] = c end)
    return fields
end

return p