Skip to content

Instantly share code, notes, and snippets.

@aradnom
Created March 2, 2015 19:02
Show Gist options
  • Save aradnom/a8bd023ff268052e5faa to your computer and use it in GitHub Desktop.
Save aradnom/a8bd023ff268052e5faa to your computer and use it in GitHub Desktop.
Given a camelcased string, return the formatted (display version) of the string, i.e. returnThisString --> Return This String
return ('' + str).match( /[A-Z]?[a-z]+/g )
.map( function ( v ) { return v.substr( 0, 1 ).toUpperCase() + v.substr( 1, v.length ); } )
.join( ' ' );
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment