如何在C++中替换“”的一组字符?

use*_*770 -1 c++

我看过来

http://en.cppreference.com/w/cpp/string/basic_string/replace

http://en.cppreference.com/w/cpp/algorithm/replace

但这似乎只是一次字符串,我不想为for我拥有的每个字符运行一个。有没有办法用一个vector<string>或一些字符数组运行这个替换方法?

就像“我喜欢 l/e*m)o)ns”变成“我喜欢柠檬”。

replace(arrayOfcharacters, "");  something like that...
Run Code Online (Sandbox Code Playgroud)

有办法吗?

Mar*_*ila 5

您可以为此使用正则表达式:

std::string text = "i like l/e*m)o)n.s";
std::regex rx("/|\\*|\\)|\\(|\\.");

auto result = std::regex_replace(text, rx, "");
Run Code Online (Sandbox Code Playgroud)