If I want to strip a string completely of its whitespaces, punctuation and numbers (i.e. anything that is not A-Z, a-z), what is the most efficient way of doing it in C++?I tried this:string strip(string in) {    string final;    for(int i = 0; i < in.length(); i++) {        if(isalpha(in[i])) final += in[i];    }    return final;}It works as expected, but is too slow on strings with ~2000 characters. I figured out that the code causing this slowness is the isalpha() call.So does anyone know of a better, more efficient way of stripping a string of everything except [A-Z][a-z] in C++?At most, the string will be 20000 characters long and I need to strip it in <1 second.Thanks in advance.EDIT:If I remove the if condition, the output will display instantly. But with the if condition, it will take about 1.6 seconds to display the output.For trying out the code, use this: http://pastebin.com/g3NtBFaD and a normal 20k char string. Then try comparing.
Most efficient way in C++ to strip strings
c++;strings;algorithm;homework