Created
January 21, 2019 22:31
-
-
Save velppa/21dad64c7171408befc39e58f04358cc to your computer and use it in GitHub Desktop.
snake meets camel
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function snakeToCamel( s ) { | |
return s.replace(/(\_\w)/g, function(m){return m[1].toUpperCase();}); | |
} | |
function camelToSnake( s ) { | |
return s.replace(/([a-z])([A-Z])/g, '$1_$2').toLowerCase(); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment