12345678910111213141516171819202122 |
- std::string removeSpecialCharacters(std::string str) {
- std::string::iterator it = str.begin();
- for(;it!=str.end();it++){
-
- bool alpha = isalnum(*it);
- bool notdash = *it != '-';
- bool notunderscore = *it != '_';
- bool notspace = *it != ' ';
-
-
- if(alpha==false && notdash && notunderscore && notspace){
- str.erase(it);
- it--;
- }
- }
- return str;
- }
|