This function is included in the "boost/algorithm/string" library. This library contains some brilliant methods which help in accomplishing string manipulations that are lacking in STL library.
This function is used to find all the occurences of a substring in the given input string. It stores the found substrings in a container provided by the user. Each part of the string is copied as a new element in the container. Popularly used output containers are std::vector<std::string> or std::list<boost::iterator_range<std::string::iterator>>
input_string : an input string
output_container : the container to hold the copies or references to the substrings
substring : the string to be searched
find_all() searches the substring case-sensitively. Another variation is present ifind_all() which searches the substring case-insensitively. Another variation is present find_all_regex() which searches the presence of substrings based on the given regular expression.
SAMPLE CODE :
using namespace std;
using namespace boost::algorithm;
string str1 = "Hi I am Hi Boost Hi Library";
string str2 = "I am very interesting";
string str3 = "I am very efficient";
First we are searching the substring "Hi" in str1. There are 3 occurences of "Hi" in str1 which are stored in v1 and are displayed. In str2 we are searching for "interesting" which occurs only once. Similarly in str3 we are searching for 'e'. We are displaying the number of times the letter 'e' occurs in str3 i.e., 3.