I'm experimenting with the cleanest way to express splitting by an optional character.
This approach is pretty decent, with one exception: empty strings turn data into nil as well. I'd like data to always be a string.
LA62RA7SUK6ADGTKNZ7PSDKHMWHOJB2YTOTFG3COUV7YYTA6YNUAC
table.insert(result, {data=line})
local line_info = {}
local line_reader = line:gmatch('[^'..Metadata_separator..']+')
--? local line_reader = line:gmatch('[^\x1e]*')
line_info.data = line_reader()
line_info.data2 = line_reader()
print(line_info.data, line_info.data2)
print(line_info.data == nil, line_info.data2 == nil)
print(type(line_info.data), type(line_info.data2))
-- works
--? for data, data2 in line:gmatch('([^\x1e]*)\x1e([^\x1e]*)') do
--? print(data)
--? print(data2)
--? print(data2 == nil)
--? print(type(data2))
--? print(#data2)
--? end
--? for data in line:gmatch('[^\x1e]+') do
--? print(data)
--? print(data == nil)
--? print(type(data))
--? print(#data)
--? end
table.insert(result, line_info)