On Jun 7, 2006, at 2:54, Austin Ziegler wrote: > On 6/6/06, darren kirby <bulliver / badcomputer.org> wrote: >> fileroot, type = filename.split(/regex here?/) > >> I cannot find a way to write a regex that only matches the last >> period in the >> filename. Is there an elegant way to do this? > > ext = File.extname(filename) > file = File.basename(filename, ext) Equivalent, but I like the semantics a little better require 'pathname' f = Pathname.new(filename) f.basename f.extname pathname is very handy - see the standard library docs: http://ruby- doc.org/stdlib/libdoc/pathname/rdoc/index.html