This example converts str1 to upper case and trims spaces from the start and the end
of the string. str2 is then created as a copy of str1 with "hello" replaced with "goodbye".
This example demonstrates several important concepts used in the library:

Container parameters:
Unlike in the STL algorithms, parameters are not specified only in the form
of iterators. The STL convention allows for great flexibility,
but it has several limitations. It is not possible to stack algorithms together,
because a container is passed in two parameters. Therefore it is not possible to use
a return value from another algorithm. It is considerably easier to write
to_lower(str1), than to_lower(str1.begin(), str1.end()).

The magic of Boost.Range
provides a uniform way of handling different string types.
If there is a need to pass a pair of iterators,
boost::iterator_range
can be used to package iterators into a structure with a compatible interface.

Copy vs. Mutable:
Many algorithms in the library are performing a transformation of the input.
The transformation can be done in-place, mutating the input sequence, or a copy
of the transformed input can be created, leaving the input intact. None of
these possibilities is superior to the other one and both have different
advantages and disadvantages. For this reason, both are provided with the library.

Algorithm stacking:
Copy versions return a transformed input as a result, thus allow a simple chaining of
transformations within one expression (i.e. one can write trim_copy(to_upper_copy(s))).
Mutable versions have void return, to avoid misuse.

Naming:
Naming follows the conventions from the Standard C++ Library. If there is a
copy and a mutable version of the same algorithm, the mutable version has no suffix
and the copy version has the suffix _copy.
Some algorithms have the prefix i
(e.g. ifind_first()).
This prefix identifies that the algorithm works in a case-insensitive manner.

The predicates determine whether if a substring is contained in the input string
under various conditions. The conditions are: a string starts with the substring,
ends with the substring,
simply contains the substring or if both strings are equal. See the reference for
boost/algorithm/string/predicate.hpp for more details.

In addition the algorithm all() checks
all elements of a container to satisfy a condition specified by a predicate.
This predicate can be any unary predicate, but the library provides a bunch of
useful string-related predicates and combinators ready for use.
These are located in the boost/algorithm/string/classification.hpp header.
Classification predicates can be combined using logical combinators to form
a more complex expressions. For example: is_from_range('a','z') || is_digit()

Trimming

When parsing the input from a user, strings usually have unwanted leading or trailing
characters. To get rid of them, we need trim functions:

It is possible to trim the spaces on the right, on the left or on both sides of a string.
And for those cases when there is a need to remove something else than blank space, there
are _if variants. Using these, a user can specify a functor which will
select the space to be removed. It is possible to use classification
predicates like is_digit() mentioned in the previous paragraph.
See the reference for the boost/algorithm/string/trim.hpp.

We have used find_last() to search the text for "ll".
The result is given in the boost::iterator_range.
This range delimits the
part of the input which satisfies the find criteria. In our example it is the last occurrence of "ll".
As we can see, input of the find_last() algorithm can be also
char[] because this type is supported by
Boost.Range.
The following lines transform the result. Notice that
boost::iterator_range has familiar
begin() and end() methods, so it can be used like any other STL container.
Also it is convertible to bool therefore it is easy to use find algorithms for a simple containment checking.

Replace Algorithms

Find algorithms can be used for searching for a specific part of string. Replace goes one step
further. After a matching part is found, it is substituted with something else. The substitution is computed
from the original, using some transformation.

For the complete list of replace and erase functions see the
reference.
There is a lot of predefined function for common usage, however, the library allows you to
define a custom replace() that suits a specific need. There is a generic find_format()
function which takes two parameters.
The first one is a Finder object, the second one is
a Formatter object.
The Finder object is a functor which performs the searching for the replacement part. The Formatter object
takes the result of the Finder (usually a reference to the found substring) and creates a
substitute for it. Replace algorithm puts these two together and makes the desired substitution.

Find Iterator

An extension to find algorithms it the Find Iterator. Instead of searching for just a one part of a string,
the find iterator allows us to iterate over the substrings matching the specified criteria.
This facility is using the Finder to incrementally
search the string.
Dereferencing a find iterator yields an boost::iterator_range
object, that delimits the current match.

There are two iterators provided find_iterator and
split_iterator. The former iterates over substrings that are found using the specified
Finder. The latter iterates over the gaps between these substrings.

Note that the find iterators have only one template parameter. It is the base iterator type.
The Finder is specified at runtime. This allows us to typedef a find iterator for
common string types and reuse it. Additionally make_*_iterator functions help
to construct a find iterator for a particular range.

Split

Split algorithms are an extension to the find iterator for one common usage scenario.
These algorithms use a find iterator and store all matches into the provided
container. This container must be able to hold copies (e.g. std::string) or
references (e.g. iterator_range) of the extracted substrings.

Two algorithms are provided. find_all() finds all copies
of a string in the input. split() splits the input into parts.

First example show how to construct a container to hold references to all extracted
substrings. Algorithm ifind_all() puts into FindVec references
to all substrings that are in case-insensitive manner equal to "abc".

Second example uses split() to split string str1 into parts
separated by characters '-' or '*'. These parts are then put into the SplitVec.
It is possible to specify if adjacent separators are concatenated or not.