function to find extension in file name string

0 views
Skip to first unread message

Bartee Lamar

unread,
Jan 8, 2008, 7:07:46 AM1/8/08
to rubyonra...@googlegroups.com
I am very new to regular expressions. ( and RoR ).

I need to find the extension in a filename on a string.

I tried several RE's but cannot get one to work that will find the 1st
dot from the end of a file name.

Also, to use this as a function for all of the applications I think it
should go in the LIB subdirectory. Is that correct?

TIA
--
Posted via http://www.ruby-forum.com/.

Xavier Noria

unread,
Jan 8, 2008, 7:12:02 AM1/8/08
to rubyonra...@googlegroups.com
On Jan 8, 2008, at 1:07 PM, Bartee Lamar wrote:

> I am very new to regular expressions. ( and RoR ).
>
> I need to find the extension in a filename on a string.

Please check File.extname.

-- fxn

Bartee Lamar

unread,
Jan 8, 2008, 8:02:33 AM1/8/08
to rubyonra...@googlegroups.com

Welllllllllll....

LOL... Really.....

I hate when the answer is soooo simple.

I guess I need to start reading ALL of the specs.

But Thanks for your quick response and EXCELLENT answer.

...bartee...

Reply all
Reply to author
Forward
0 new messages