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.
Synopsis
Declared in <absl/strings/str_replace.h>
int
StrReplaceAll(
std::initializer_list<std::pair<std::string_view, std::string_view>> replacements,
std::string* target);
Description
Example:
std::string s = std::string("\$who bought \$count #Noun. Thanks $who!"); int count; count = absl::StrReplaceAll({{"$count", absl::StrCat(5)}, {"$who", "Bob"}, {"#Noun", "Apples"}}, &s); EXPECT_EQ(count, 4); EXPECT_EQ("Bob bought 5 Apples. Thanks Bob!", s);
Return Value
The number of substitutions that occurred.
Parameters
Name |
Description |
replacements |
The key/value pairs of sequences to replace. |
target |
The string to modify in place. |
Created with MrDocs