testA = "test.test test.test" local t1 = {} for X in string.gfind (testA, "[^ ]+") do table.insert (t1 ,X) end local first = table.concat(t1, "", 1, 1); --output/first test.test testA = "11.11.11.11 test.test" local t2 = {} for X in string.gfind (testA, "[^ ]+") do table.insert (t2 ,X) end local first = table.concat(t2, "", 1, 1); --output/first 11.11.11.11 testA = "100.100.100.100 test.test" local t3 = {} for X in string.gfind (testA, "[^ ]+") do table.insert (t3 ,X) end local first = table.concat(t3, "", 1, 1); --output/first 100.100.100.100 test.test
Does anyone know why the 3rd item wont split with gfind? , cant figure out why
it works for two strings but not the third.
Your problem is that a tab character is not the same thing as a space. If you want to skip all whitespace characters, you need to actually skip whitespace characters, not just regular space: