Lua字符串中使用通配符来表示空格。

我想搜索一个很长的字符串以查找各种项,这些项可能像这样:

"test     test"
"test            test"
"test test"

因此,我不知道测试之间可能有多少空格,所以是否有通配符可以使用,告诉 Lua 只要在测试之间至少有一个空格字符,它就已找到“test”和“test”?

点赞
用户107090
用户107090

尝试匹配这个模式:"test +test"

下面是一些代码:

function try(s)
    print(s:match("test +test")~=nil,s)
end

try"test     test"
try"test            test"
try"test test"
try"test,test"
try"test, test"
2012-06-10 19:17:57