I know you can do something like:
\"SomeWordHere\".underscore.gsub(\"_\", \" \")
to get \"some word here\".
I thought that might
You can use a regular expression:
puts "SomeWordHere".gsub(/[a-zA-Z](?=[A-Z])/, '\0 ').downcase
Output:
some word here
One reason you might prefer this is if your input could contain dashes or underscores and you don't want to replace those with spaces:
puts "Foo-BarBaz".underscore.gsub('_', ' ')
puts "Foo-BarBaz".gsub(/[a-zA-Z](?=[A-Z])/, '\0 ').downcase
Output:
foo bar baz
foo-bar baz