On 6/30/07, Aaron Smith <beingthexemplary / gmail.com> wrote:
> how can a take a string file name like MyTestCase.rb and change it to
> my_test_case.rb?

I'm a novice at Ruby, but this might help:

irb(main):013:0> 'MyTestCase'.gsub(/[A-Z]/) {
irb(main):014:1*   |p| '_' + p.downcase
irb(main):015:1> }
=> "_my_test_case"

then:

irb(main):020:0> "_my_test_case"[1..-1]
=> "my_test_case"


Veterans can provide more succinct ways though :)

Cheers,
Swaroop
-- 
ion | power your music
Get your own ion right now at www.ion.co.in !