本站页面(多半)转载自萌娘百科的同名页面,依CC BY-NC-SA 3.0引入,贡献者可以在历史页查询。
因各种原因页面内容可能和源页面有所出入,非本站特有页面内容请以萌娘百科为准。
因各种原因页面内容可能和源页面有所出入,非本站特有页面内容请以萌娘百科为准。
- 你好~!欢迎来到萌娘百科镜像站!如需查看或编辑,请联系本站管理员注册账号。
- 本镜像站和其他萌娘百科的镜像站无关,请注意分别。
Module:Str test
跳到导航
跳到搜索
local module = {} function module.main(frame) local args = frame.args local str = args[1] local ptn = mw.text.decode(mw.text.unstripNoWiki(args[2])) if mw.ustring.find(str, ptn) == nil then return '' else return 1 end end function module.MultiMatch(frame) local parent = frame:getParent() if parent and parent:getTitle() == "Template:Str substr" then frame = parent end local args = frame.args local str = args[1] local result = "" local i = 2 while(frame.args[i])do local ptn = mw.text.decode(mw.text.unstripNoWiki(args[i])) local found = mw.ustring.match(str, ptn) result = result .. (found and "1" or "0") i = i+1 end return result end function module.Switch(frame) local parent = frame:getParent() if parent and parent:getTitle() == "Template:Str switch" then frame = parent end local str = frame.args[1] for key, value in pairs(frame.args) do if type(key) == "string" and key ~= "#default" then local ptn = mw.text.decode(mw.text.trim(mw.text.unstripNoWiki(value))) if ptn ~= "" and mw.ustring.match(str, ptn) then return key end end end return frame.args["#default"] or "" end return module