Open ooolky opened 10 months ago
char charsToRemove[] = ": ";
for (unsigned int i = 0; i < strlen(charsToRemove); ++i)
{
output_name.erase(std::remove(output_name.begin(), output_name.end(), charsToRemove[i]), output_name.end());
}
步骤
#include <algorithm>
#include <string>
void some_func() {
std::string s = "example string";
std::replace( s.begin(), s.end(), 'x', 'y'); // replace all 'x' to 'y'
}
#include <regex>
...
std::string string("hello $name");
string = std::regex_replace(string, std::regex("\\$name"), "Somename");