Created
October 15, 2019 18:06
-
-
Save CEOehis/a775340a82daa617e4ad82ca433f325d to your computer and use it in GitHub Desktop.
Convert a sentence to pascal case with spaces stripped off.
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 toPascalCase(text) { | |
| text = text.trim(); | |
| return text.replace(/(\w)(\S*)(\s*)/g, // matches words and spaces | |
| function(g0,g1,g2){ | |
| return g1.toUpperCase() + g2.toLowerCase(); | |
| } | |
| ); | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment