を使用して文字列からすべてのものを削除したい場合は、次のboost::erase_all
ように実行できます。
boost::erase_all( "a1b1c1", "1" );
今、私の文字列は「abc」です。ただし、を使用して文字列からすべての数字(0〜9)を削除する場合は、削除する数字boost::erase_all
ごとに1回呼び出す必要があります。
boost::erase_all( "a1b2c3", "1" );
boost::erase_all( "a1b2c3", "2" );
boost::erase_all( "a1b2c3", "3" );
boost::is_any_of
などの他のブースト文字列アルゴリズムで機能するため、一度にすべてを削除できると思いましboost::split
たが、is_any_ofはerase_allでは機能しないようです。
boost::erase_all( "a1b2c3", boost::is_any_of( "123" ) );
// compile error
boost/algorithm/string/erase.hpp:593:13: error: no matching
function for call to ‘first_finder(const
boost::algorithm::detail::is_any_ofF<char>&)’
おそらく、私はここで明らかな何かを見落としたか、これを行うことを意図したブースト内の別の関数があります。私は標準のC++で手動でそれを行うことができますが、他の人がこれを行うためにどのようにブーストを使用しているのか興味があります。
アドバイスありがとうございます。