Using boost::replace_all
:
#include <boost/algorithm/string.hpp> // include Boost, a C++ library
...
std::string target("Would you like a foo of chocolate. Two foos of chocolate?");
boost::replace_all(target, "foo", "bar");
More Related Contents:
- Replace part of a string with another string
- Does my overload of operator
- Converting std::__cxx11::string to std::string
- Flattening iterator
- How is std::string implemented?
- Why is the destructor of a future returned from `std::async` blocking?
- Append an int to a std::string [duplicate]
- When using C headers in C++, should we use functions from std:: or the global namespace?
- declaring a priority_queue in c++ with a custom comparator
- What can and can’t I specialize in the std namespace?
- How std::bind works with member functions
- How to convert std::chrono::time_point to calendar datetime string with fractional seconds?
- Is the C++ std::set thread-safe?
- Can std::begin work with array parameters and if so, how?
- std::bind overload resolution
- do I need to close a std::fstream? [duplicate]
- BOOST_STATIC_ASSERT without boost
- C++ Add months to chrono::system_clock::time_point
- How can I use Standard Library (STL) classes in my dll interface or ABI?
- Passing rvalues through std::bind
- How to truncate a file while it is open with fstream
- cc1plus: error: unrecognized command line option “-std=c++11” with g++
- error C2065: ‘cout’ : undeclared identifier
- Why does the C++ standard algorithm “count” return a difference_type instead of size_t?
- std::remove_const with const references
- Sorting a vector of objects by a property of the object
- Syntax for using std::greater when calling std::sort in C++
- C++ std::tuple order of destruction
- std::ofstream, check if file exists before writing
- I want to kill a std::thread using its thread object? [duplicate]