lua獲取字串中單引號之間的字串

朱小勇發表於2024-06-19

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

相關文章