Skip to content

Instantly share code, notes, and snippets.

@kylealwyn
Last active October 22, 2015 18:57
Show Gist options
  • Save kylealwyn/ff7ac6c8a3a91d235bb8 to your computer and use it in GitHub Desktop.
Save kylealwyn/ff7ac6c8a3a91d235bb8 to your computer and use it in GitHub Desktop.
capitalize all words of a string
function (text) {
  return text.toString().toLowerCase()
             .replace(/[_-]/g, ' ')
             .replace(/(?:^|\s)\S/g, function(a) {
                return a.toUpperCase();
              });
  }
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment