s = "Please don't reinvent the wheel." chunks = {} for substring in s:gmatch("%S+") do table.insert(chunks, substring) end print(table.concat(chunks, ","))