Created
March 18, 2018 08:41
-
-
Save a1exlism/d8e5f05245ba5f6466408cac623c3344 to your computer and use it in GitHub Desktop.
Caused By this issue: https://stackoverflow.com/questions/6142922/replace-a-regex-capture-group-with-uppercase-in-javascript
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
function styleHyphenFormat(propertyName) { | |
function upperToHyphenLower(match) { | |
return '-' + match.toLowerCase(); | |
} | |
return propertyName.replace(/[A-Z]/g, upperToHyphenLower); | |
} | |
function cssStyle2DomStyle(sName) { | |
let result = sName.replace(/-\w/g, function (match) { | |
return match.slice(1).toUpperCase(); | |
}); | |
return result.charAt(0).toLowerCase() + result.slice(1); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment