lua - 如果字符串与通配符匹配则返回值

时间:2016-05-09 17:27:02

标签: lua

我之前从未使用过lua,并且很难找到如何根据与通配符匹配的字符串返回值...请提前感谢您的帮助。

这是我负责修改的脚本。我寻找Bob *的最后一点是我被困的地方。

if score < 3000 then
return 180
end
if score > 2999 and score < 10000 then
return 90
end
if score > 9999 and score < 25000 then
return 30
end
if score > 24999 then
return 7
end

if name = string.match(name, 'Bob*')
return 0
end
;

1 个答案:

答案 0 :(得分:1)

lua中的通配符(?*)是..*。 纠正条件:

if name = string.match(name, '^Bob.*$') then
return 0
end

PS。什么是分号和代码结束?

相关问题