Skip to content

Instantly share code, notes, and snippets.

@lx7575000
Created April 16, 2016 14:22
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save lx7575000/f5790cfea4f66efa7533d0678af650c1 to your computer and use it in GitHub Desktop.
Save lx7575000/f5790cfea4f66efa7533d0678af650c1 to your computer and use it in GitHub Desktop.
返回首字母大写
String.prototype.firstUpperCase = function(){
    return this.replace(/\b(\w)(\w*)/g, function($0, $1, $2) {
        return $1.toUpperCase() + $2.toLowerCase();
    });
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment