lua获取字符串中单引号之间的字符串

1.代码

local str = "This is 'some' text with 'single quotes'."

local pattern = "'(.-)'"

local matches = {}

for match in string.gmatch(str, pattern) do
    table.insert(matches, match)
end

for i, match in ipairs(matches) do
    print("Match " .. i .. ": " .. match)
end

 

posted @ 2024-06-19 17:20  朱小勇  阅读(2)  评论(0编辑  收藏  举报