3
我需要在Lua停止读取换行符后获取模式帮助。 我的代码:脚本Lua模式在行结束时停止
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
输出使用file2.ini:
汤姆
密码= XYZ
用户名=简
如何获得模式到达行结束后停止?
工作正常。谢谢。 – Pekinese 2014-10-02 14:49:15
确保文件以换行符结尾... – lhf 2014-10-02 14:49:19
或使用'“(UserName =)([^ \ n] *)”'或甚至是“(UserName =)(%w *)” – siffiejoe 2014-10-02 15:16:03