Created
June 28, 2023 09:46
-
-
Save daformat/3f3699f09307518b9d2e3f934481b029 to your computer and use it in GitHub Desktop.
Convert camel case to kebab case
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// convert camelCase to kebab-case | |
const kebabize = (str) => | |
str.replace( | |
/[A-Z]+(?![a-z])|[A-Z]/g, | |
(match, offset) => (offset ? '-' : '') + match.toLowerCase() | |
); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment