Skip to content

Instantly share code, notes, and snippets.

@serslon
Created June 15, 2016 13:39
Show Gist options
  • Select an option

  • Save serslon/1860d715663289f658f7640d1d7ad28f to your computer and use it in GitHub Desktop.

Select an option

Save serslon/1860d715663289f658f7640d1d7ad28f to your computer and use it in GitHub Desktop.
Convert string from downdash or dash to camelCase string
string.toLowerCase().replace(/[-_]+(.)?/g, (match, group) => group ? group.toUpperCase() : '')
/*
Incoming string like Data_Example-string out string dataExampleString
*/
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment