From: ara.t.howard@... Date: 2006-08-20T01:06:07+09:00 Subject: Re: Convert "ThisIsSomeString" to "this_is_some_string"? On Sun, 20 Aug 2006, Daniel Schierbeck wrote: > Joshua Muheim wrote: >> Hi all >> >> What's the fastest way to convert "ThisIsSomeString" to >> "this_is_some_string"? > > I believe this is the fastest way, though it may not catch all cases (numbers > and such) > > def lowerize(str) # ?? > str.gsub(/([a-z])([A-Z])/, '\1_\2').downcase > end > > > Cheers, > Daniel > depending on what you want, the snake_case code i posted works differently: irb(main):025:0> lowerize 'BARFoo' => "barfoo" irb(main):026:0> snake_case 'BARFoo' => "bar_foo" neither is right - just fyi. -a -- to foster inner awareness, introspection, and reasoning is more efficient than meditation and prayer. - h.h. the 14th dali lama