StrReplaceAll overloads
Synopses
Declared in <absl/strings/str_replace.h>
Replaces character sequences within a given string with replacements provided within an initializer list of key/value pairs.
[[nodiscard]]
std::string
StrReplaceAll(
std::string_view s,
std::initializer_list<std::pair<std::string_view, std::string_view>> replacements);
Overload of StrReplaceAll() to replace character sequences within a given output string in place with replacements provided within an initializer list of key/value pairs, returning the number of substitutions that occurred.
int
StrReplaceAll(
std::initializer_list<std::pair<std::string_view, std::string_view>> replacements,
std::string* target);
Overload of StrReplaceAll() to accept a container of key/value replacement pairs (typically either an associative map or a std::vector of std::pair elements). A vector of pairs is generally more efficient.
template<typename StrToStrMapping>
std::string
StrReplaceAll(
std::string_view s,
StrToStrMapping const& replacements);
Overload of StrReplaceAll() to replace patterns within a given output string in place with replacements provided within a container of key/value pairs.
template<typename StrToStrMapping>
int
StrReplaceAll(
StrToStrMapping const& replacements,
std::string* target);
Return Value
-
A new string with the replacements applied.
-
The number of substitutions that occurred.
Parameters
Name |
Description |
s |
The string to search for replacements. |
replacements |
The key/value pairs of sequences to replace. |
target |
The string to modify in place. |
Created with MrDocs