Skip to content

Instantly share code, notes, and snippets.

@eugene-sy
Created May 26, 2014 08:13
Show Gist options
  • Save eugene-sy/8917b784bfb9dd2008db to your computer and use it in GitHub Desktop.
Save eugene-sy/8917b784bfb9dd2008db to your computer and use it in GitHub Desktop.
Convert string with snake_case to UpperCamelCase and lowerCamelCase
snakeToCamel: (s) ->
s.replace(/(_\w)/g, (m) -> return m[1].toUpperCase() )
snakeToUpperCamel: (s) ->
s.charAt(0).toUpperCase() + s.slice(1).replace(/(_\w)/g, (m) -> return m[1].toUpperCase() )
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment