Created
September 3, 2013 20:34
-
-
Save jec006/6429184 to your computer and use it in GitHub Desktop.
Turns a camelCase or Capital Case word into snake-case.
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
/** | |
* Take a camel case word and turn it into snake case | |
* i.e. layoutBlock to layout-block | |
*/ | |
String.prototype.toSnakeCase = function() { | |
return this.replace(/ /g, '-').replace(/([a-z0-9])([A-Z0-9])/g, '$1-$2').toLowerCase(); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment