How can I find the words consist of the letters inside the keyword in Lua?

后端 未结 3 476
北恋
北恋 2021-01-24 02:30

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

3条回答
  •  长情又很酷
    2021-01-24 03:18

    Run the loop on your arrays and use string.find to check against this long word.

    for idx = 1, #stored_words do
       local word = stored_words[idx]
       if string.find(long_word, word, 1, true) then
          print(word .. " matches part of " .. long_word)
       end
    end
    

提交回复
热议问题