←模块:Basic欢迎来到Undertale社区维基(*`∀´*)ノ亻,如果想要参与条目创建或编辑,请先登录哦因为以下原因,您没有权限编辑本页: 您请求的操作仅限属于该用户组的用户执行:用户 您可以查看和复制此页面的源代码。 local p = {} -- function p.empty(item) if item == nil or #item == 0 then return nil else return item end end -- function p.is_include_value(item, tab) for _, value in ipairs(tab) do if value == item then return true end end return false end -- function p.is_include_key(item, tab) for key, _ in pairs(tab) do if key == item then return true end end return false end -- function p.is_find_value(item, tab) for _, value in ipairs(tab) do if mw.ustring.find(value, item) then return true end end return false end -- function p.is_find_key(item, tab) for key, _ in pairs(tab) do if mw.ustring.find(key, item) then return true end end return false end -- function p.str_split(str, split_pattern) if str == nil then return {} end local result = {} local current_token = "" local escape_char = [[\]] local i = 1 local len = mw.ustring.len(str) local escaped = false while i <= len do local char = mw.ustring.sub(str, i, i) local is_split_char = mw.ustring.find(split_pattern, char, 1, true) and not escaped if char == escape_char and not escaped then escaped = true elseif not is_split_char then if escaped and char == split_pattern then current_token = current_token .. char escaped = false else current_token = current_token .. char escaped = false end elseif #current_token > 0 then table.insert(result, current_token) current_token = "" escaped = false end i = i + mw.ustring.len(char) end if #current_token > 0 then table.insert(result, current_token) end return result end -- function p.containschinese(text) return string.match(text, '[\x{4e00}-\x{9fa5}]') ~= nil end -- function p.trim(text) return (mw.ustring.gsub(text, "^%s*(.-)%s*$", "%1")) end -- function p.escape_pattern_string(str) local escape_map = { ["-"] = "%-", ["?"] = "%?", } return mw.ustring.gsub(str, ".", function(c) return escape_map[c] or c end) end -- return p 本页使用的模板: 模块:Basic/doc(查看源代码)返回模块:Basic。