【发布时间】:2018-05-10 15:44:36
【问题描述】:
我在获取字符串时遇到问题。 这是我的代码:
conf = "option fn_o 'Operator'"
print(conf)
local s, e, pa = string.find(conf, "\b(?!option|fn_o)\b\w+")
print(s, e, pa)
我只想得到一个操作员。在 Javascript 中,该正则表达式运行良好,但在 Lua 中却不行。我认为没有问题,因为 Lua 是基于 json 的,所以它类似于 javascript。有什么问题吗?
【问题讨论】:
-
嗯,Lua 没有正则表达式支持,它只有 Lua 模式。另请参阅lua-users.org/wiki/JsonModules
-
Lua 不是基于 json。
-
坦率地说,我对“Lua 基于 JSON”的评论感到有点生气。 Javascript 的部分灵感来自 Lua。
标签: json regex string lua luci