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