Sea.util.split = function ( text, separator, t, noPurge ) local value; local mstart, mend = 1; local oldn, numMatches = 0, 0; local regexKey = "([^"..separator.."]+)"; local sfind = strfind; -- string.find if not in WoW (n calls) if ( not t ) then t = {}; else oldn = table.getn(t); end -- Using string.find instead of string.gfind to avoid garbage generation mstart, mend, value = sfind(text, regexKey, mstart); while (value) do numMatches = numMatches + 1; t[numMatches] = value mstart = mend + 1; mstart, mend, value = sfind(text, regexKey, mstart); end if ( not noPurge ) then for i = numMatches+1, oldn do t[i] = nil; end end table.setn(t, numMatches); return t; end