local s = "http://example.com/image.jpg"
print(string.match(s, "/(.-)%.jpg"))
这给了我
--> /example.com/image
但是我想得到
--> image
最佳答案
如果您确定在文件名之前的字符串中有 /
,则可以这样做:
print(string.match(s, ".*/(.-)%.jpg"))
贪心匹配 .*/
将根据需要在最后一个 /
处停止。
关于string - 为什么这不非贪婪地匹配并只给我图像名称?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/44709917/