Skip to content

Instantly share code, notes, and snippets.

@kentbrew
Created March 6, 2014 22:42
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 kentbrew/9401391 to your computer and use it in GitHub Desktop.
Save kentbrew/9401391 to your computer and use it in GitHub Desktop.
// http://stackoverflow.com/questions/10425287/convert-string-to-camelcase-with-regular-expression
// fetch me my camel, Jeeves
var toCamelCase function (str) {
return str.toLowerCase().replace(/-(.)/g, function(match, group1) {
return group1.toUpperCase();
});
}
@bennypowers
Copy link

ES2015:

let toCamelCase = (s) => s.toLowerCase().replace(/-(.)/g, (m, g) => g.toUpperCase());

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