gmatch is your friend:
Code:
local str = "0, 4, 7, 10"
local t = {}
for num in string.gmatch(str, "%d+") do
t[#t+1] = tonumber(num)
end
It iterates through the input string for every instance that matches the given pattern. In this case,
%d means "a numeral" and
+ tells it "grab as many as you can". The spaces and/or commas break up that sequence, so it can get each value separately.
Personally I'd rewrite it to put them in a table to start with and use
table.concat to make a string for the few occasions where you need one.