From: Sam Duncan Date: 2010-12-09T09:19:51+09:00 Subject: Re: Splitting on capital letters This might be ridiculous, but ... ("BenefitsAndFeatures".gsub(/[A-Z]/) { |c| "-#{c}" }).reverse.chomp('-').reverse Sam On 09/12/10 13:04, Tony Arcieri wrote: > Here's an ActiveSupport-powered roflscale method: > > >> "BenefitsAndFeatures".underscore.split('_').map(&:capitalize).join('-') >> > => "Benefits-And-Features" > > > On Wed, Dec 8, 2010 at 5:02 PM, Ralph Shnelvar wrote: > > >> JB> Whether or not this is a good way may be up for debate, but it's *a* >> way: >> >> irb(main):001:0>> >> "BenefitsAndFeatures".split(/([[:upper:]][[:lower:]]*)/).delete_if(&:empty?).join("-") >> =>> "Benefits-And-Features" >> >> This is sooo far beyond my skill level. >> >> I'm gonna have to study this one for a while. >> >> Thanks! >> >> Ralph >> > > > >