Skip to content

Instantly share code, notes, and snippets.

@codeRhythm
Created September 4, 2018 01:06
Show Gist options
  • Save codeRhythm/fcd91cf9f4001316446b01763524d4d7 to your computer and use it in GitHub Desktop.
Save codeRhythm/fcd91cf9f4001316446b01763524d4d7 to your computer and use it in GitHub Desktop.
remove-in-c++
string s = "\r\n\t \t这是随便写的一句话。\t\t ";
  
size_t n = s.find_last_not_of( " \r\n\t" );
if( n != string::npos )
{
    s.erase( n + 1 , s.size() - n );
}
  
n = s.find_first_not_of ( " \r\n\t" );
if( n != string::npos )
{
    s.erase( 0 , n );
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment