I don't program in Lua. However when I get stuck, Google Search is my first go to as I know that I am not the only one who has encountered the problems that I experience. A quick search proves that every time.
So, the internet can be a powerful help tool, and your best friend and mentor, when used. This search link has tonnes of solutions for you:
Lua get words[
^]