Created
October 20, 2011 18:43
-
-
Save cyberfox/1301931 to your computer and use it in GitHub Desktop.
JavaScript humanize method.
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
com = { cyberfox: {} }; | |
/** | |
* Convert a property name into a human readable string by replacing _ with | |
* spaces, and upcasing the first letter of each word. | |
* | |
* @param {string} property The property name to convert into a readable name. | |
* @return {string} The property name converted to a friendly readable format. | |
* @private | |
*/ | |
com.cyberfox.humanize_ = function(property) { | |
return property.replace(/_/g, ' ') | |
.replace(/(\w+)/g, function(match) { | |
return match.charAt(0).toUpperCase() + match.slice(1); | |
}); | |
}; |
Just helped fix tons of IE8 errors. Thanks!
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
This do not match special characters (as they are not word)
Eg.
furgão
will becomeFurgãO
I ended using this version: