Module:Tool:修订间差异

来自Arcaea中文维基
(添加函数)
(调整)
第8行: 第8行:


--从字符串中移除某字符
--从字符串中移除某字符
function p.LuaReomve(str,remove)
function p.LuaReomve(frame)
str=frame.args.str
remove=frame.args.remove
    local lcSubStrTab = {}
    local lcSubStrTab = {}
    while true do
    while true do

2021年3月8日 (一) 12:49的版本

可在Module:Tool/doc创建此模块的帮助文档

local p={}
-- 小工具集

--时间格式转换
function p.time(frame)
	return os.date("%Y/%m/%d", frame.args.time)
end

--从字符串中移除某字符
function p.LuaReomve(frame)
	str=frame.args.str
	remove=frame.args.remove
    local lcSubStrTab = {}
    while true do
        local lcPos = string.find(str,remove)
        if not lcPos then
            lcSubStrTab[#lcSubStrTab+1] =  str    
            break
        end
        local lcSubStr  = string.sub(str,1,lcPos-1)
        lcSubStrTab[#lcSubStrTab+1] = lcSubStr
        str = string.sub(str,lcPos+1,#str)
    end
    local lcMergeStr =""
    local lci = 1
    while true do
        if lcSubStrTab[lci] then
            lcMergeStr = lcMergeStr .. lcSubStrTab[lci] 
            lci = lci + 1
        else 
            break
        end
    end
    return lcMergeStr
end

return p