std::regex_replace
| Defined in header <regex>
  | ||
| template< class OutputIterator, class BidirectionalIterator,           class Traits, class CharT, | (1) | (since C++11) | 
| template< class OutputIterator, class BidirectionalIterator,           class Traits, class CharT > | (2) | (since C++11) | 
| template< class Traits, class CharT,           class STraits, class SAlloc, | (3) | (since C++11) | 
| template< class Traits, class CharT,           class STraits, class SAlloc > | (4) | (since C++11) | 
| template< class Traits, class CharT,           class STraits, class SAlloc > | (5) | (since C++11) | 
| template< class Traits, class CharT > std::basic_string<CharT>  | (6) | (since C++11) | 
If there are no matches, copies the entire sequence into out as-is.
If flags contains std::regex_constants::format_no_copy, the non-matched subsequences are not copied into out.
If flags contains std::regex_constants::format_first_only, only the first match is replaced.
| Contents | 
[edit] Parameters
| first, last | - | the input character sequence, represented as a pair of iterators | 
| s | - | the input character sequence, represented as std::basic_string or character array | 
| e | - | the std::basic_regex that will be matched against the input sequence | 
| flags | - | the match flags of type std::regex_constants::match_flag_type | 
| fmt | - | the regex replacement format string, exact syntax depends on the value of flags | 
| out | - | output iterator to store the result of the replacement | 
[edit] Return value
[edit] Exceptions
May throw std::regex_error to indicate an error condition.
[edit] Example
#include <iostream> #include <regex> #include <string> int main() { std::string text = "Quick brown fox"; std::regex vowel_re("a|o|e|u|i"); std::cout << std::regex_replace(text, vowel_re, "[$&]") << '\n'; }
Output:
Q[u][i]ck br[o]wn f[o]x
[edit] See also
| (C++11) | attempts to match a regular expression to any part of the character sequence (function template) | 
| (C++11) | options specific to matching (typedef) | 

