C++ 我不知道';如果不是在c+中,我不知道如何删除U+;
这段代码可以工作,但有点有限,所以如果它不等于一个字母,我想删除它 我知道我必须使用::isalpha而不是::ispunct,但如果它不等于::isalpha,我不知道如何将其删除。我一直盯着这个问题看,但没有找到答案,因为我不懂C++ 我不知道';如果不是在c+中,我不知道如何删除U+;,c++,erase,remove-if,C++,Erase,Remove If,这段代码可以工作,但有点有限,所以如果它不等于一个字母,我想删除它 我知道我必须使用::isalpha而不是::ispunct,但如果它不等于::isalpha,我不知道如何将其删除。我一直盯着这个问题看,但没有找到答案,因为我不懂 textFile[i].erase(remove_if(textFile[i].begin(), textFile[i].end(), ::ispunct), textFile[i].end()); 非常感谢您的帮助。我还没有编译,但这应该可以: textFile
textFile[i].erase(remove_if(textFile[i].begin(), textFile[i].end(), ::ispunct), textFile[i].end());
非常感谢您的帮助。我还没有编译,但这应该可以:
textFile[i].erase(
remove_if(textFile[i].begin(), textFile[i].end(), std::not1(std::ptr_fun(::isalpha))),
textFile[i].end());
这里的链接是:
struct not_a_character : std::unary_function<char, bool> {
bool operator()(char c) const {
return !isalpha(c);
}
};
我还没有编译,但这应该可以:
textFile[i].erase(
remove_if(textFile[i].begin(), textFile[i].end(), std::not1(std::ptr_fun(::isalpha))),
textFile[i].end());
这里的链接是:
struct not_a_character : std::unary_function<char, bool> {
bool operator()(char c) const {
return !isalpha(c);
}
};