Skip to content

Instantly share code, notes, and snippets.

@chrislaughlin
Created October 7, 2013 20:19
Show Gist options
  • Save chrislaughlin/6874254 to your computer and use it in GitHub Desktop.
Save chrislaughlin/6874254 to your computer and use it in GitHub Desktop.
Underscore.string
//format into name style case formatting
_.str.capitalize('chris')
=> "Chris"
//Compress white space
_.clean(" foo bar ")
=> 'foo bar'
//Swaps the case of the string
_.swapCase('hELLO')
=> 'Hello'
//Counts the number of times a sub string is found
_('Hello world').count('l')
=> 3
//insets a string a the given index
_('Hello ').insert(6, 'world')
=> 'Hello world'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment