Posted 04 April 2016 - 07:36 PM
                I found this function to split strings:
My problem:
split('a\nb\n\nc', '\n') –> {'a','b','c'}
This can be useful, but for my code it isnt.
How can I modify the function to get:
{'a','b','','c'}
Granted, I can't deal with string.gmatch.
                
                    
local split = function(inputstr, sep)
  if sep == nil then
	sep = "%s"
  end
  sep = tostring(sep)
  local t={} ; i=1
  for str in string.gmatch(inputstr, "([^"..sep.."]+)") do
	t[i] = str
	i = i + 1
  end
  return t
end
My problem:
split('a\nb\n\nc', '\n') –> {'a','b','c'}
This can be useful, but for my code it isnt.
How can I modify the function to get:
{'a','b','','c'}
Granted, I can't deal with string.gmatch.
Edited on 04 April 2016 - 08:37 PM
                
             
         
                 
                