Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save catindev/9bf61bb4ba14c6b2a7fcc4c618e36de6 to your computer and use it in GitHub Desktop.
Save catindev/9bf61bb4ba14c6b2a7fcc4c618e36de6 to your computer and use it in GitHub Desktop.
Javascript convert camelcase to dash (hyphen)
function camelCaseToDash( myStr ) {
return myStr.replace( /([a-z])([A-Z])/g, '$1-$2' ).toLowerCase();
}
var myStr = camelCaseToDash( 'thisString' );
alert( myStr ); // => this-string
@bestimmaa
Copy link

thx

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment