#!/usr/local/bin/lua function reverseWords(str) list = {} for word in string.gfind(str, "(%w+)") do table.insert(list, 1, word) end return (table.concat(list, " ")) end print(reverseWords(" one two three four "))