lua-users home
lua-l archive

[Date Prev][Date Next][Thread Prev][Thread Next] [Date Index] [Thread Index]


Hi, I'm new to Lua and could use some help with a function to parse a filespec.

I could write about 100 lines of code to reverse(), find(separator), then everything before that in the original string is the path (except on Windows, where you have to consider driver letter), everything after is the filename, and if there's a '.', then filename is everything before the '.', ext is everything after.

I'm thinking a function like this

drive, path, filename, ext = ParseFilespec(arg[0])

or even

drive, path, filename, ext, separator, OS = ParseFilespec(arg[0])

I know this may not be appropriate for this mailing list, but I think this is the kind of exercise that can help a lot of news users understand Lua a little bit better.

Does anyone have any suggestions?

Thanks,
Jeff