我想将一个字符串拆分为一个由多个分隔符分隔的数组。
local delim = {",", " ", "."}
local s = "a, b c .d e , f 10, M10 , 20,5"
结果表应如下所示:
{"a", "b", "c", "d", "e",  "f", "10", "M10", "20", "5"}
分隔符可以是空格、逗号或点。如果两个分隔符(例如空格和逗号)紧随其后,则应折叠它们,并忽略其他空格。
此代码通过构建分隔符集的补码模式来根据需要分割字符串。
local delim = {",", " ", "."}
local s = "a, b c .d e , f 10, M10 , 20,5"
local p = "[^"..table.concat(delim).."]+"
for w in s:gmatch(p) do
        print(w)
end
调整代码以将“单词”保存在表中。