Created
October 7, 2013 20:19
-
-
Save chrislaughlin/6874254 to your computer and use it in GitHub Desktop.
Underscore.string
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//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