我正在尝试解析一个字符串,但我是模式匹配的新手。这是我的代码:
str = "One[0:0,0,0,0,0,0,0,0,0,0,0,0:1][0:1,0,1,0,0,0,1,1,1,0,0,0:0.5]/Two[0:0,0,0,0,0,0,0,0,0,0,0,0:1.5]/"
for i in string.gmatch(str, "[%a%s]*[%[%]%d:,]*/") do
print("sequence: "..i)
end
它应该打印 One[0:0,0,0,0,0,0,0,0,0,0,0,0:1][0:1,0,1,0,0,0,1, 1,1,0,0,0:0.5] 两个[0:0,0,0,0,0,0,0,0,0,0,0,0:1.5]
但它会打印
序列:5]/序列:5]/