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