Skip to content

Instantly share code, notes, and snippets.

@blizzrdof77
Forked from youssman/regex-camelCase-to-dash.js
Last active January 4, 2018 19:21
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save blizzrdof77/9ac97b0536b9e1a8abbf3fd05355c3d0 to your computer and use it in GitHub Desktop.
Save blizzrdof77/9ac97b0536b9e1a8abbf3fd05355c3d0 to your computer and use it in GitHub Desktop.
Javascript convert camelcase to dash (hyphen)
/**
* Convert camelCase string to lowercase string with dashes (pretty permalink style ;-)
*
* @return String
*/
String.prototype.camelCaseToDashed = function() {
return this.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