Most efficient way in C++ to strip strings
A few thoughts which come to my mind, without having actually profiled your code:


Try passing std::string as reference-to-const to avoid a copy (in case your std::string implementation is not Copy-On-Write).
Reserve space in the std::string by calling reserve.
Avoid calling std::string::length repeatedly, memorize the value.
Avoid indexing the string repeatedly, use an iterator instead.


For what it's worth, you could try a different (more functional) way to implement this function. Some may consider this idiomatic, other will find it harder to read. Your call -maybe just for the fun of it, to see how it performs (remember to enable optimizations!):

#include &lt;algorithm&gt;
#include &lt;functional&gt;
#include &lt;locale&gt;
#include &lt;string&gt;

std::string strip( const std::string &amp;s ) {
    std::string result;
    result.reserve( s.length() );

    std::remove_copy_if( s.begin(),
                         s.end(),
                         std::back_inserter( result ),
                         std::not1( std::ptr_fun( isalpha ) ) );

    return result;
}