it can be oneliner - `File.basename(file)[/^(.*)#{BASEFILE_SUFFIX}$/, 1]` ( string method [] have also format regexp, captured