Skip to content

Instantly share code, notes, and snippets.

@youssman
Created November 5, 2014 11:19
Show Gist options
  • Save youssman/745578062609e8acac9f to your computer and use it in GitHub Desktop.
Save youssman/745578062609e8acac9f 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
@bilogic
Copy link

bilogic commented May 5, 2024

is there one that deals with paths? /CamelCase/Path/Here to /camel-case/path/here

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