使用Lua的
string.find
函数时,可以传递第四个可选参数以启用普通搜索。来自Lua维基的说明:
The pattern argument also allows more complex searches. See the PatternsTutorial for more information. We can turn off the pattern matching feature by using the optional fourth argument plain. plain takes a boolean value and must be preceeded by index. E.g.,
= string.find("Hello Lua user", "%su") -- find a space character followed by "u" 10 11 = string.find("Hello Lua user", "%su", 1, true) -- turn on plain searches, now not found nil
基本上,我想知道如何使用Lua的string.gsub
函数实现相同的简单搜索。