如何在lua regex中获取特定的单词/字符串

时间:2017-11-27 11:51:12

标签: json regex string lua luci

我有一个问题是得到一个字符串。 这是我的代码:

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。有什么问题吗?

1 个答案:

答案 0 :(得分:0)

Lua不支持开箱即用的完整正则表达式,但有些库可以使用。

Lua包含模式,足以满足您的任务。

此代码获取单引号内的字符串:

app = Flask(__name__, static_folder="static", root_path="../")

模式显示:找到单引号并捕获所​​有内容,直到下一个单引号。

相关问题