Skip to content

Instantly share code, notes, and snippets.

@dalibormesaric
Last active December 30, 2017 10:41
Show Gist options
  • Save dalibormesaric/7feaf8f3a01ce305f50e to your computer and use it in GitHub Desktop.
Save dalibormesaric/7feaf8f3a01ce305f50e to your computer and use it in GitHub Desktop.
Convert hyphens to camel case and convert camel case to hyphens
("thisIsTest").replace(/([a-z][A-Z])/g, function (g) { return g[0] + '-' + g[1].toLowerCase() });
"this-is-test"
("this-is-test").replace(/-([a-z])/g, function (g) { return g[1].toUpperCase(); });
"thisIsTest"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment