I am playing a bit with lfs, and I was wondering how to "split" a path into directories.
I found a lot of examples and snippets on how to retrieve a base directory , filenames and extensions from a given path, but I didn't find anything to "split" a path (string) as I like.
"/sdcard/dir1/banana/" ---> "/sdcard/dir1/" "banana/" or ---> "/sdcard/" "dir1/" "banana/" |
"C:/dir1/banana/" ----> "C:/dir1/" "banana/" or ----> "C:" "/dir1/" "banana/" |
I found about the lua string pattern, I thought I would be using string.match, but after some hours wasted on that, I think that writing patterns is something currently out of my league.. ~X(
I could really use some hint
My goal was being able to follow the directory path backwards: starting from banana to root.
Thank you
Comments
If you have a copy of my Book, on Page 74, there is a function that exists to split strings. It is simply 4 lines of code and are
cheers,
Jayant C Varma
Author of :
* Learn Lua for iOS Game Development, Apress
* Xcode 6 Essentials, Packt
* More iPhone Development with Swift, Apress
* More iPhone Development with Objective-C, Apress
Likes: ar2rsawseen, SinisterSoft, pie, talis, bali001
Author of Learn Lua for iOS Game Development from Apress ( http://www.apress.com/9781430246626 )
Cool Vizify Profile at https://www.vizify.com/oz-apps
local pattern = string.format("([^%s]+)", sep) was missing a " )"