Forum: Ruby How I can get name of file?

Announcement (2017-05-07): www.ruby-forum.com is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see rubyonrails.org/community and ruby-lang.org/en/community for other Rails- und Ruby-related community platforms.
Faa86d6ab4a5d5d80cfb11197941e70d?d=identicon&s=25 Ilyas (Guest)
on 2006-05-25 20:07
I have this is string:
/adfsd/dfsdf/funny-videos---gay-fight.mpeg

and I have this code:
@original_file_path = file_path
name = @original_file_path.match(/\/[a-zA-Z0-9_-]+\./)
if name
   puts name.values_at(0)
end

Result of code is
/funny-videos---gay-fight.

I want to get it: funny-videos---gay-fight
how I can get name of file?
4b174722d1b1a4bbd9672e1ab50c30a9?d=identicon&s=25 Ryan Leavengood (Guest)
on 2006-05-25 20:15
(Received via mailing list)
On 5/25/06, Ilyas <iiskakov@gmail.com> wrote:
> I have this is string:
> /adfsd/dfsdf/funny-videos---gay-fight.mpeg
[snip]
>
> I want to get it: funny-videos---gay-fight
> how I can get name of file?

irb(main):001:0>
File.basename('/adfsd/dfsdf/funny-videos---gay-fight.mpeg', '.mpeg')
=> "funny-videos---gay-fight"

Ryan
This topic is locked and can not be replied to.