Find full string using partial string lua

只愿长相守 提交于 2020-01-06 04:51:08

问题


I tried to find the whole string in a table without writing the full string.

Example:

maintable = {"SecondString", "FirstString"}
c = "First"

How would I be able to use string c to find the whole name of FirstString without typing the whole string name?


回答1:


You have to search the table:

for k,v in pairs(maintable) do
    if v:match(c) then print(k,v) end
end


来源:https://stackoverflow.com/questions/50952236/find-full-string-using-partial-string-lua

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!