Return the file extension portion of a filename

This was another question in a skills evaluation test Write a regular expression for the following code that will trim off the extension from a filename: $ext = preg_replace(‘/xxxxx/’, ’’, $filename); My solution: $ext = preg_replace(‘/^.*\.([^.]+)$/D’, ‘$1’, $filename); I find regular expressions pretty tricky, so usually end up using an online tool like this: In […]