I want to split a string only once so the output looks like this:
STRING1: STRING.STRING1.STRING2
OUT1: STRING
OUT2: STRING1.STRING2
I tried to make a function since I can't find a function that someone else made, and it kind of worked. For some reason, if you set the separator to "." then the function completely stops working and sets the default start and end values to 1, 1 Because of this my current output is:
STRING1: STRING.STRING1.STRING2
OUT1:
OUT2: TRING.STRING1.STRING2
Does anyone know what I'm doing wrong in this function:
function splitOnce(inputstr, sep)
local s, e = inputstr:find(sep)
local t = {}
--print(inputstr)
--print(sep)
--print("start: "..tostring(s)..", end: "..tostring(e))
table.insert(t, inputstr:sub(1, s - 1))
table.insert(t, inputstr:sub(e + 1, -1))
return t
end