“模块:StringUtils”的版本间的差异
		
		
		
		
		
		跳到导航
		跳到搜索
		
				
		
		
	
|  (建立内容为“local p = {}  function p.split_or_empty(value, sep)     if value and #value > 0 then         return mw.text.split(value, sep)     else         return {}     end e…”的新页面) | |||
| (未显示同一用户的1个中间版本) | |||
| 第6行: | 第6行: | ||
|      else |      else | ||
|          return {} |          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 | ||
| end | end | ||
| return p | return p | ||
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