boost::algorithm::replace_last — Replace last algorithm.
// In header: <boost/algorithm/string/replace.hpp> template<typename SequenceT, typename Range1T, typename Range2T> ( Input, Search, Format);
Replace the last match of the search string in the input with the format string. Input sequence is modified in-place.
Parameters:
Format
A substitute string
Input
An input string
Search
A substring to be searched for