我有以下代码用于在空格之间拆分字符串:
text = "I am 'the text'"
for string in text:gmatch("%S+") do
print(string)
end
结果如下:
I
am
'the
text'
但是我需要做这个:
I
am
the text --[[yep, without the quotes]]
我该怎么做? 编辑: 补充一下问题,想法是从一个程序向另一个程序传递参数。这是我正在处理的拉取请求,目前正在审核中:https://github.com/mpv-player/mpv/pull/1619
"^
"替换为
[[^["']]],将
"'$"替换为
[[['"]$]]`即可。您还需要检查开头引号是否与结尾引号匹配。 - Paul Kulchenko