There are some discussions here, and utility functions, for splitting strings, but I need an ad-hoc one-liner for a very simple task.
I have the following string:
Just changing * to + works.
local s = "one;two;;four" local words = {} for w in s:gmatch("([^;]+)") do table.insert(words, w) print(w) end
The magic character * represents 0 or more occurrene, so when it meet ',', lua regarded it as a empty string that [^;] does not exist.