In this article we will discuss how to replace all occurrences of a sub string with new string in C++.

For example, we have a string i.e.

“Boost Library is simple C++ Library”

And we want replace all occurrences of ‘Lib’ with XXX. Let’s see the different methods to do it,

Find & Replace all sub strings – using STL


Find & Replace all sub strings – using Boost::replace_all


Find & Replace all Case Insensitive Sub Strings using Boost::ireplace_all



Join LinkedIn Group of Python Professional Developers who wish to expand their network and share ideas.

You can also follow us On Twitter :

Click Here to Subscribe for more Articles / Tutorials like this.