Created
January 2, 2012 00:40
-
-
Save Jim-Holmstroem/1548816 to your computer and use it in GitHub Desktop.
Remove things (for example space) based on condition in std::string c++
This file contains 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
//string.erase(std::remove_if(string.begin(),string.end(),&condition),string.end()) | |
#include <algorithm> | |
#include <string> | |
bool condition(char c) | |
{ | |
return c==' '; //simple example | |
} | |
std::string string = "The string you wan't to remove things in."; | |
string.erase(std::remove_if(string.begin(),string.end(),&condition),string.end()) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment