I need in function,which do splitting of lines in lua. As i know,for splittings of lines by sep in lua i can use gmatch function,but i want to get sep in table to. For example,if i use pattern %s*
and line 1 2 3 4
, I expect getting table like:{1, ,2, ,3, ,4}
,i.e size of table must be seven. Thanks very much everybody for the help.
Asked
Active
Viewed 118 times
0

Egor Skriptunoff
- 23,359
- 2
- 34
- 64

Aleksandr Kozlovskiy
- 51
- 9
-
`local s="1 2 3 4"; for w in s:gsub("%S+", "\0%0\0"):gmatch"%Z+" do print(w) end` – Egor Skriptunoff Oct 28 '19 at 05:50
-
And this will works for any separator? – Aleksandr Kozlovskiy Oct 28 '19 at 21:09