문제

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