Overload of StrReplaceAll() to replace patterns within a given output string in place with replacements provided within a container of key/value pairs.

Synopsis

Declared in <absl/strings/str_replace.h>

template<typename StrToStrMapping>
int
StrReplaceAll(
    StrToStrMapping const& replacements,
    std::string* target);

Description

Example:

std::string s = std::string("if (ptr < &foo)"); int count = absl::StrReplaceAll({{"&", "&amp;"}, {"<", "&lt;"}, {">", "&gt;"}}, &s); EXPECT_EQ(count, 2); EXPECT_EQ("if (ptr &lt; &amp;foo)", s);

Return Value

The number of substitutions that occurred.

Parameters

Name

Description

replacements

The container of key/value pairs of sequences to replace.

target

The string to modify in place.

Created with MrDocs