Вопрос

Is it possible to use string.match and return a capture until the last . character to stop at the extension part?

Это было полезно?

Решение

local str = "filename.lua.txt"
local cap = str:match("(.+)%..+")
print(cap)

Output: filename.lua

The key in this pattern is the greediness of + and to use %. to represent the literal .

Лицензировано под: CC-BY-SA с атрибуция
Не связан с StackOverflow
scroll top