I'm trying to parse a txt file which is in the format of host-name IP mac-address in Lua. All three separated with spaces, to try and then store it into a table using Lua.
I've tried doing this using :match function but can't see to get it to work.
function parse_input_from_file()
array ={}
file = io.open("test.txt","r")
for line in file:lines() do
local hostname, ip, mac = line:match("(%S+):(%S+):(%S+)")
local client = {hostname, ip, mac}
table.insert(array, client)
print(array[1])
end
end
It keeps on printing the location in memory of where each key/value is stored (I think).
I'm sure this is a relatively easy fix but I can't seem to see it.
line:match("(.+)%s+(.+)%s+(.+)")