[Date Prev][Date Next][Thread Prev][Thread Next]
- Subject: Function to parse filespec
- From: Jeff Stone <stone1343@...>
- Date: Tue, 26 May 2009 13:19:19 -0400
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)
drive, path, filename, ext, separator, OS = ParseFilespec(arg)
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?