Skip to content

Instantly share code, notes, and snippets.

@linus-amg
Created October 9, 2014 19:03
Show Gist options
  • Save linus-amg/77b48dd63cd339683c6e to your computer and use it in GitHub Desktop.
Save linus-amg/77b48dd63cd339683c6e to your computer and use it in GitHub Desktop.
var result = str.replace(/(?:^\w|[A-Z]|\b\w)/g, function(letter, index) {
var result = index === 1 ? letter.toLowerCase() : (!isNaN(last) ? letter.toUpperCase() : ' '+letter.toUpperCase());
last = parseInt(letter);
return result;
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment