#include <iostream>
#include <string>
#include <algorithm>
int main()
{
std::string str = "ab*+cd*+ef*+gh*+ij*+kl*+" ;
std::cout << str << '\n' ;
constexpr char asterisk = '*' ;
// erase first asterisk
auto pos = str.find(asterisk) ;
if( pos != std::string::npos ) str.erase(pos,1) ;
std::cout << str << '\n' ;
// erase last asterisk
pos = str.rfind(asterisk) ;
if( pos != std::string::npos ) str.erase(pos,1) ;
std::cout << str << '\n' ;
// erase all asterisk
while( ( pos = str.find(asterisk) ) != std::string::npos ) str.erase(pos,1) ;
std::cout << str << '\n' ;
// erase all '+'
str.erase( std::remove( str.begin(), str.end(), '+' ), str.end() ) ;
std::cout << str << '\n' ;
}
I2luY2x1ZGUgPGlvc3RyZWFtPgojaW5jbHVkZSA8c3RyaW5nPgojaW5jbHVkZSA8YWxnb3JpdGhtPgoKaW50IG1haW4oKQp7CiAgICBzdGQ6OnN0cmluZyBzdHIgPSAiYWIqK2NkKitlZiorZ2gqK2lqKitrbCorIiA7CiAgICBzdGQ6OmNvdXQgPDwgc3RyIDw8ICdcbicgIDsKCiAgICBjb25zdGV4cHIgY2hhciBhc3RlcmlzayA9ICcqJyA7CgogICAgLy8gZXJhc2UgZmlyc3QgYXN0ZXJpc2sKICAgIGF1dG8gcG9zID0gc3RyLmZpbmQoYXN0ZXJpc2spIDsKICAgIGlmKCBwb3MgIT0gc3RkOjpzdHJpbmc6Om5wb3MgKSBzdHIuZXJhc2UocG9zLDEpIDsKICAgIHN0ZDo6Y291dCA8PCBzdHIgPDwgJ1xuJyAgOwoKICAgIC8vIGVyYXNlIGxhc3QgYXN0ZXJpc2sKICAgIHBvcyA9IHN0ci5yZmluZChhc3RlcmlzaykgOwogICAgaWYoIHBvcyAhPSBzdGQ6OnN0cmluZzo6bnBvcyApIHN0ci5lcmFzZShwb3MsMSkgOwogICAgc3RkOjpjb3V0IDw8IHN0ciA8PCAnXG4nICA7CgogICAgLy8gZXJhc2UgYWxsIGFzdGVyaXNrCiAgICB3aGlsZSggKCBwb3MgPSBzdHIuZmluZChhc3RlcmlzaykgKSAhPSBzdGQ6OnN0cmluZzo6bnBvcyApIHN0ci5lcmFzZShwb3MsMSkgOwogICAgc3RkOjpjb3V0IDw8IHN0ciA8PCAnXG4nICA7CgogICAgLy8gZXJhc2UgYWxsICcrJwogICAgc3RyLmVyYXNlKCBzdGQ6OnJlbW92ZSggc3RyLmJlZ2luKCksIHN0ci5lbmQoKSwgJysnICksIHN0ci5lbmQoKSApIDsKICAgIHN0ZDo6Y291dCA8PCBzdHIgPDwgJ1xuJyAgOwp9Cg==