From: Young Moon Date: 2007-08-18T21:59:57+09:00 Subject: Re: Working with String Hi, irb(main):035:0> "/foo/foo.gif".split("/")[-1] => "foo.gif" irb(main):038:0> "/foo/foo.gif".split(".")[-1] => "gif" On Aug 18, 5:03 pm, Dipesh Batheja wrote: > Hi need some help with string manipulation. I have a string representing > full path of a file. Example "/foo/foo.gif". I need to just extract the > file name i.e "foo.gif" from this string. I also need to extract the > file type i.e "gif" from it in a separate string. Can anybody tell me > how to do it using regular expressions in Ruby. I know this can be done > using String.gsub, but i am too bad at reg expressions. And if someone > can point me to good source for learning reg expressions then it would > be really helpful. > > Thanks > -- > Posted viahttp://www.ruby-forum.com/.