Lua 中的字符串匹配和小写字符

我需要帮助处理小写字符和字符串匹配...

items.xml

    <item id="2432" article="a" name="fire axe">
    <attribute key="description" value="刃上有魔法火焰。" />
    <attribute key="weight" value="4000" />
    <attribute key="defense" value="16" />
    <attribute key="attack" value="38" />
    <attribute key="elementFire" value="11" />
    <attribute key="weaponType" value="axe" />
    <attribute key="extradef" value="1" />
</item>
<item id="2493" article="a" name="Demon Helmet">
    <attribute key="description" value="你听到了内部的邪恶低语。" />
    <attribute key="weight" value="2950" />
    <attribute key="armor" value="10" />
    <attribute key="slotType" value="head" />
</item>

现在,这是我的函数:

function seachItem(name)
local items = io.open("data/items/items.xml", "r"):read("*all")
local get = items:match('name="' .. name ..'"')
if get == nil or get == "" then
    return false
end
return true
end

但仅适用于小写字母的物品,比如fire axe。

该函数无法以小写字母找到“Demon helmet”,有没有办法改变匹配函数使其在小写字母时生效?

示例:

local var = "demon helmet" -- 小写字母
  if seachItem(var) then
      print("Ok")
 end
点赞