Improved autodetection of file prefixes

Uses a better-defined regular expression to handle pathological
prefixes, such as Perkin-Elmer TIFF files with duplicate entries, e.g.,
'file-000000_01000.tif'