【发布时间】:2013-11-26 16:43:43
【问题描述】:
我在 Lua 中遇到了一个问题,即检查字符串值是否没有出现在另一个字符串中。
这就是我在 Javascript 中可能会这样做的方式:
'my string'.indexOf('no-cache') === -1 // true
但在 Lua 中,我尝试使用 string 模块,这给了我意想不到的响应:
string.find('my string', 'no-cache') -- nil, that's fine but..
string.find('no-cache', 'no-cache') -- nil.. that's weird
string.find('no-cache', 'no') -- 1, 2 here it's right.. strange..
【问题讨论】: