File indexing completed on 2025-12-16 10:08:38
0001
0002
0003
0004
0005
0006
0007
0008
0009
0010
0011
0012
0013
0014
0015
0016
0017
0018
0019
0020
0021 #ifndef BOOST_REGEX_V5_REGEX_REPLACE_HPP
0022 #define BOOST_REGEX_V5_REGEX_REPLACE_HPP
0023
0024
0025 namespace boost{
0026
0027 template <class OutputIterator, class BidirectionalIterator, class traits, class charT, class Formatter>
0028 OutputIterator regex_replace(OutputIterator out,
0029 BidirectionalIterator first,
0030 BidirectionalIterator last,
0031 const basic_regex<charT, traits>& e,
0032 Formatter fmt,
0033 match_flag_type flags = match_default)
0034 {
0035 regex_iterator<BidirectionalIterator, charT, traits> i(first, last, e, flags);
0036 regex_iterator<BidirectionalIterator, charT, traits> j;
0037 if(i == j)
0038 {
0039 if(!(flags & regex_constants::format_no_copy))
0040 out = BOOST_REGEX_DETAIL_NS::copy(first, last, out);
0041 }
0042 else
0043 {
0044 BidirectionalIterator last_m(first);
0045 while(i != j)
0046 {
0047 if(!(flags & regex_constants::format_no_copy))
0048 out = BOOST_REGEX_DETAIL_NS::copy(i->prefix().first, i->prefix().second, out);
0049 out = i->format(out, fmt, flags, e);
0050 last_m = (*i)[0].second;
0051 if(flags & regex_constants::format_first_only)
0052 break;
0053 ++i;
0054 }
0055 if(!(flags & regex_constants::format_no_copy))
0056 out = BOOST_REGEX_DETAIL_NS::copy(last_m, last, out);
0057 }
0058 return out;
0059 }
0060
0061 template <class traits, class charT, class Formatter>
0062 std::basic_string<charT> regex_replace(const std::basic_string<charT>& s,
0063 const basic_regex<charT, traits>& e,
0064 Formatter fmt,
0065 match_flag_type flags = match_default)
0066 {
0067 std::basic_string<charT> result;
0068 BOOST_REGEX_DETAIL_NS::string_out_iterator<std::basic_string<charT> > i(result);
0069 regex_replace(i, s.begin(), s.end(), e, fmt, flags);
0070 return result;
0071 }
0072
0073 }
0074
0075 #endif
0076
0077