- string replacement function for std::string
namespace j2 {
std::string replace(const std::string& text,
const std::string& find_token,
const std::string& replace_token);
}
int main()
{
std::string before = "hello\tworld\r\n123\n456";
std::string strFind = "\r\n";
std::string strReplace = "";
std::cout << "Before : "<< before << std::endl << std::endl;
std::string after = j2::replace(before, strFind, strReplace);
std::cout << "After : " << after << std::endl;
/*
Before : hello world
123
456
After : hello world123
456
*/
return 0;
}
- MIT License
- https://github.com/JayTwoLab/replace_std_string