Overload of StrReplaceAll() to replace patterns within a given output string in place with replacements provided within a container of key/value pairs.
Declared in <absl/strings/str_replace.h>
template<typename StrToStrMapping>
int
StrReplaceAll(
StrToStrMapping const& replacements,
std::string* target);
Example:
std::string s = std::string("if (ptr < &foo)"); int count = absl::StrReplaceAll({{"&", "&"}, {"<", "<"}, {">", ">"}}, &s); EXPECT_EQ(count, 2); EXPECT_EQ("if (ptr < &foo)", s);
The number of substitutions that occurred.
| Name | Description |
|---|---|
| replacements | The container of key/value pairs of sequences to replace. |
| target | The string to modify in place. |