Skip to content

Instantly share code, notes, and snippets.

@Jim-Holmstroem
Created January 2, 2012 00:40
Show Gist options
  • Save Jim-Holmstroem/1548816 to your computer and use it in GitHub Desktop.
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++
//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