Skip to content

Instantly share code, notes, and snippets.

@pastukh-dm
Forked from nblackburn/camelToKebab.js
Created August 27, 2019 14:31
Show Gist options
  • Save pastukh-dm/de6da0a64f2f00a2f4b57cdbf1240f1f to your computer and use it in GitHub Desktop.
Save pastukh-dm/de6da0a64f2f00a2f4b57cdbf1240f1f to your computer and use it in GitHub Desktop.
Convert a string from camel case to kebab case.
module.exports = (string) => {
return string
.replace(/([a-z0-9])([A-Z])/g, '$1-$2')
.replace(/([A-Z])([A-Z])(?=[a-z])/g, '$1-$2')
.toLowerCase();
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment