Created
December 16, 2020 08:29
-
-
Save yeyuguo/440f78268a4b80f01348174ac2c95d4e to your computer and use it in GitHub Desktop.
驼峰命名转成 xx-xx 命名【kebabCase】
This file contains hidden or 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
| function kebabCase(str) { | |
| const hyphenateRE = /([^-])([A-Z])/g; | |
| return str | |
| .replace(hyphenateRE, '$1-$2') | |
| .replace(hyphenateRE, '$1-$2') | |
| .toLowerCase(); | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
kebabCase('testABCName') // "test-a-b-c-name"