I am writing a piece of software, and It require me to handle data I get from a webpage with libcurl. When I get the data, for some reason it has extra line breaks in it. I
#include
#include
#include
std::string s = "Hello World!";
s.erase(std::remove_if(s.begin(), s.end(),
std::not1(std::ptr_fun(std::isalnum)), s.end()), s.end());
std::cout << s << std::endl;
Results in:
"HelloWorld"
You use isalnum
to determine whether or not each character is alpha numeric, then use ptr_fun
to pass the function to not1
which NOTs the returned value, leaving you with only the alphanumeric stuff you want.