You can use string.match
:
fullpath = "c:/abc/def/test.lua"
dir = string.match(fullpath, ".*/")
file = string.match(fullpath, ".*/(.*)")
Here in the pattern, .*
is greedy, so that it will match as much as it can before it matches /
UPDATE:
As @Egor Skriptunoff points out, this is better:
dir, file = fullpath:match'(.*/)(.*)'