From: Tim Hunter Date: 2009-01-05T01:35:24+09:00 Subject: Re: Finding filename from a URL Sam Fent wrote: > Hi all, > > This is just a basic parsing question, really. I'm trying to work out > how I would process a URL such as > "http://www.example.com/x/y/z/myfile.txt" and get back the filename > "myfile". Basically the pattern is to get the past part of the string > after the final /, and then strip off the filetype. > > Any help would be much appreciated, > Thanks! > > Sam $ irb irb(main):001:0> x = "http://www.example.com/x/y/z/myfile.txt" => "http://www.example.com/x/y/z/myfile.txt" irb(main):002:0> File.basename(x) => "myfile.txt" irb(main):003:0> File.basename(x, '.txt') => "myfile" -- RMagick: http://rmagick.rubyforge.org/