mirror of
https://github.com/PHIDIAS0303/ExpCluster.git
synced 2025-12-30 12:31:41 +09:00
Added table.autokey
This commit is contained in:
@@ -484,3 +484,14 @@ function table.json(lua_table)
|
|||||||
else return "{"..table.concat(result,",").."}"
|
else return "{"..table.concat(result,",").."}"
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
--- Returns the closest match to a key
|
||||||
|
-- @usage tbl = {foo=1,bar=2}
|
||||||
|
-- table.autokey(tbl,'f') -- return 1
|
||||||
|
function table.autokey(tbl,str)
|
||||||
|
local _return = {}
|
||||||
|
for key,value in pairs(keys) do
|
||||||
|
if string.contains(string.lower(string),string.lower(key)) then table.insert(_return,value) end
|
||||||
|
end
|
||||||
|
return _return[1] or false
|
||||||
|
end
|
||||||
Reference in New Issue
Block a user