For example, I have a keyword \"abandoned\" and I want to find the words that contains letters of this keyword such as \"done\", \"abandon\", band\", from the arrays I stored t
Try this:
W={"done", "abandon", "band"}
for k,w in pairs(W) do
W[w]=true
end
function findwords(s)
for i=1,#s do
for j=i+1,#s do
local w=s:sub(i,j)
if W[w] then print(w) end
end
end
end
findwords("abandoned")
If you don't have an array of words, you can load a dictionary:
for w in io.lines("/usr/share/dict/words") do
W[w]=true
end