“模块:StringUtils”的版本间的差异
跳到导航
跳到搜索
| 第7行: | 第7行: | ||
return {} | return {} | ||
end | end | ||
| + | end | ||
| + | |||
| + | function p.split(s, sep) | ||
| + | return mw.text.split(s, sep) | ||
| + | end | ||
| + | |||
| + | function p.join(l, sep) | ||
| + | return mw.text.listToText(l, sep, sep) | ||
end | end | ||
2021年1月1日 (五) 10:51的最新版本
此模块的文档可以在模块:StringUtils/doc创建
local p = {}
function p.split_or_empty(value, sep)
if value and #value > 0 then
return mw.text.split(value, sep)
else
return {}
end
end
function p.split(s, sep)
return mw.text.split(s, sep)
end
function p.join(l, sep)
return mw.text.listToText(l, sep, sep)
end
function p.assert_not_empty(s)
if s and #s == 0 then
return nil
else
return s
end
end
return p