From: Martin DeMello Date: 2009-02-24T23:34:24+09:00 Subject: Re: what is best idiom to remove file extension On Tue, Feb 24, 2009 at 5:39 AM, bwv549 wrote: > All great answers - much better than what I was doing before. > > To summarize then... > > full pathname with no extension: >    File.expand_path(File.basename(fname, File.extname(fname)) > > easy to remember and read: >    fname.chomp(File.extname(fname) ) > > shortest: >    fname[/.*(?=\..+$)/] Note that you've lost your robustness with that last: irb> fname = '.vimrc' => ".vimrc" irb> fname[/.*(?=\..+$)/] => "" irb> fname.chomp(File.extname(fname) ) => ".vimrc" martin