我需要在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..