I have a number of files and they are all called something like name_version_xyz.ext
.
In my Java code I need to extract the name and the version part of the filename. I can accomplish this using lastIndexOf
where I look for underscore, but I don't think that's the nicest solution. Can this be done with a regexp somehow?
Note that the "name" part can contain any number of underscores.