模块:Utils/String
来自「荏苒之境」
此模块的文档可以在模块:Utils/String/doc创建
local utils = {}
utils.trim = function(str)
local res = string.gsub(str, "^%s*(.-)%s*$", "%1")
return res
end
utils.split = function(str, sep)
if sep == nil then
sep = "%s"
end
local t = {}
for str in string.gmatch(str, "([^"..sep.."]+)") do
table.insert(t, str)
end
return t
end
utils.unword = function(str)
local t = {}
for str in string.gmatch(str, "([^%s]+)") do
table.insert(t, str)
end
return t
end
utils.match_xml_noattr = function(str, tag)
local res = string.match(str, "<"..tag..">(.-)</"..tag..">")
return res
end
return utils