There are plenty of posts about the opposite way.
But how to I convert camelCase to camel-case in ruby? My regex-game is pretty low ... here is it the other way around:
But how to I convert camelCase to camel-case in ruby? My regex-game is pretty low ... here is it the other way around:
Mã:
def underscore(string)
string.gsub(/::/, '/').
gsub(/([A-Z]+)([A-Z][a-z])/,'\1_\2').
gsub(/([a-z\d])([A-Z])/,'\1_\2').
tr("-", "_").
downcase
end