By the pattern %/
or /
, you are telling string.match
to look for a string /
and that's what you got. Try with this:
local mystring = "/var/log/test.log"
print(string.match(mystring, ".+/"))
Here the pattern .+/
means to look for one or more whatever characters(.
) followed by a /
. +
means it's greedy, i.e, match as long as possible.