Last active
December 15, 2023 03:19
-
-
Save nblackburn/875e6ff75bc8ce171c758bf75f304707 to your computer and use it in GitHub Desktop.
Convert a string from 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
module.exports = (string) => { | |
return string.replace(/([a-z0-9]|(?=[A-Z]))([A-Z])/g, '$1-$2').toLowerCase(); | |
}; |
@bradgreens @ibockowsky Yeah, I should have reported back when I found out about lack of support with lookbehind assertions in Safari. I ran into that during browser testing too.
I've updated my original comment with what I used to get around Safari's lack of lookbehind assertion support.
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
I was curious why.... so here is why.
https://stackoverflow.com/a/51568859