Skip to content

Instantly share code, notes, and snippets.

@LeoFeitosa
Forked from ryanhs/ucwords.js
Created July 11, 2018 14:58
Show Gist options
  • Save LeoFeitosa/ead636c2da1e1034cf4731f62ba53bfc to your computer and use it in GitHub Desktop.
Save LeoFeitosa/ead636c2da1e1034cf4731f62ba53bfc to your computer and use it in GitHub Desktop.

Revisions

  1. @rickycheers rickycheers created this gist Jan 15, 2013.
    7 changes: 7 additions & 0 deletions ucwords.js
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,7 @@
    String.prototype.ucwords = function() {
    str = this.toLowerCase();
    return str.replace(/(^([a-zA-Z\p{M}]))|([ -][a-zA-Z\p{M}])/g,
    function(s){
    return s.toUpperCase();
    });
    };