Lua pattern to stop when end of line
I need help for a pattern in Lua that stops to read after a line break. My code:
function getusers(file)
local list, close = {}
local user, value = string.match(file,"(UserName=)(.*)")
print(value)
f:close()
end
f = assert(io.open('file2.ini', "r"))
local t = f:read("*all")
getusers(t)
--file2.ini--
user=a
UserName=Tom
Password=xyz
UserName=Jane
Script output using file2.ini:
Tom
Password = hug
UserName = Jane
How do I make the pattern stop after it reaches the end of the line?
+3
source to share