I am in need of a regular expression that can remove the extension of a filename, returning only the name of the file.
Here are some examples of inputs and outputs:<
/^(.+)(\.[^ .]+)?$/
Test cases where this works and others fail:
The common thread above is, of course, "malformed" file extensions. But you always have to think about those corner cases. :P
Test cases where this fails:
How to handle these is problematic and best decided on a project-specific basis.