rename file name but keep extension
[man]pathinfo[/man] with the PATHINFO_EXTENSION constant will get you the extension from a file name (with or without complete pathing)
Use regular expressions to cut particular substrings from the filename and access them.
Unless you have special requirements concerning the "file extension", pathinfo is a better solution than regular expressions because it is more descriptive of what is happening (assuming you use the named constant), and the reader does not need to check the regex pattern.