Created
August 14, 2022 02:59
-
-
Save lewdev/721795e9228d38d71363899e92e5e723 to your computer and use it in GitHub Desktop.
π¨βπ» Format & Capitalize Camel-cased Strings
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
| <p id=o></p> | |
| <script> | |
| const capCamel = s => ( | |
| // capitalize the first character | |
| s.charAt(0).toUpperCase() | |
| // Split by capital letter | |
| + s.substring(1).split(/(?=[A-Z])/).join` ` | |
| ); | |
| o.innerHTML = capCamel("splitSelectionByLine"); //Result: "Split Selection By Line" | |
| </script> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment