How to strip all non alphanumeric characters from a string in c++?

后端 未结 11 1469
野的像风
野的像风 2020-11-30 02:07

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

11条回答
  •  孤独总比滥情好
    2020-11-30 02:36

    The following works for me.

    str.erase(std::remove_if(str.begin(), str.end(), &ispunct), str.end());
    str.erase(std::remove_if(str.begin(), str.end(), &isspace), str.end());
    

提交回复
热议问题