For extracting file extensions, substr is preferable since you know the start index and the fixed length of the extension.