actually, Erel's answer does the job well.
Agreed, regular expressions are great, but for anything past simple literal matches it gets complex quickly.
Why do you think it is better to use theString built-in functions
Huh? Better? That doesn't sound like me - I try to stay out of those philosophical wars. Let me check.
Righto, what I actually said was that using regex here was like cracking nuts with a sledgehammer. I'll stand by that. If anything, it's a positive statement about the power of regex.
Later I said it was probably simpler to use the built-in string methods. I'll stand by that too. If regex was simple, this thread would not exist.
My thinking was that if you are using this to split off the file extension to determine the type of the file, then splitting the full filename into more or fewer than 2 strings is probably not what you want.
Eg, for the example I used in post #6, for the file "Monty Python.doc.zip" then you probably want to know that it is a zip file, so that you can handball it to a decompression library.
Try feeding your app filenames like "noextension" and "lots.of.extensions.txt" and "dot.but.no.extension." and "" and "." and see what happens.