Created
May 13, 2015 18:48
-
-
Save kn9ts/dd89ac25e4f0e4dcc6f6 to your computer and use it in GitHub Desktop.
Function to capitalise the 1st letters in a string
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 TO CAPITALIZE THE !ST LETTERS IN A STRING | |
String.prototype.capitalize = function() { | |
return this.replace(/(^|\s)([a-z])/g, function(m, p1, p2) { | |
return p1 + p2.toUpperCase(); | |
}); | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment