Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
是否可以使用string.match并返回捕获,直到最后一个.字符停止在扩展部分?
string.match
.
local str = "filename.lua.txt" local cap = str:match("(.+)%..+") print(cap)
输出:filename.lua
filename.lua
这种模式的关键是贪婪+和用来%.表示字面量.
+
%.