David Alan Black wrote:
> 
> Hi --
> 
> On Mon, 5 Aug 2002, Jim Freeze wrote:
> 
> > On Mon, Aug 05, 2002 at 12:57:30PM +0900, Gavin Sinclair wrote:
> > > > On Mon, Aug 05, 2002 at 11:37:12AM +0900, David Alan Black wrote:
> > > >>
> > > >> Try this:
> > > >>
> > > >>   /\.[^.]*$/
> > > >>
> > > >> which forces the match to start at the right-most '.' on the line.
> > > >>
> > > >  or this:
> > > >
> > > >   /\w+$/
> > >
> > > Hmm.. that'll do! :)  Thanks.
> >
> > Note that /\w+$/ will not match all extensions. E.g.,
> >
> >    fred.my-dashed-ext
> >
> > will return ext.
> > David replied with my first (unpoosted) attempt.
> > To be sure you get everything past that last '.', use:
> >
> >   /\.([^.]*)$/.match(file)[1]
> 
> I guess Gavin didn't need to include the '.' itself in the match (it
> was there in the first one, but if /\w+$/ works on his example then it
> must not be needed).  If it's not needed one could just do:
> 
>    /[^.]*$/.match(file)[0]

Now wouldn't all this be much simpler if we had a method
along the lines of 'basename', which would pull off the
extension (or suffix) for us?  We already have File::basename
and File::dirname, so why not a File::last-part-of-the-name-name?

Or what about a 'File::parts' which returns an array of: 
directory (or nil), root name (or nil), suffix(es) (or nil).
Would that be more Ruby-esqe?

--
Mike Hall
http://www.enteract.com/~mghall