[#absl-StrReplaceAll-0c]
= xref:absl.adoc[absl]::StrReplaceAll
:relfileprefix: ../
:mrdocs:

Overload of `StrReplaceAll()` to accept a container of key&sol;value replacement pairs (typically either an associative map or a `std&colon;&colon;vector` of `std&colon;&colon;pair` elements)&period; A vector of pairs is generally more efficient&period;

== Synopsis

Declared in `&lt;absl&sol;strings&sol;str&lowbar;replace&period;h&gt;`

[source,cpp,subs="verbatim,replacements,macros,-callouts"]
----
template&lt;typename StrToStrMapping&gt;
std::string
StrReplaceAll(
    std::string&lowbar;view s,
    StrToStrMapping const& replacements);
----

== Description

Examples&colon;

std&colon;&colon;map&lt;const absl&colon;&colon;string&lowbar;view, const absl&colon;&colon;string&lowbar;view&gt; replacements&semi; replacements&lsqb;&quot;$who&quot;&rsqb; &equals; &quot;Bob&quot;&semi;&rsqb; replacements&lsqb;&quot;$count&quot;&rsqb; &equals; &quot;5&quot;&semi;&rsqb; replacements&lsqb;&quot;&num;Noun&quot;&rsqb;&equals; &quot;Apples&quot;&semi; std&colon;&colon;string s &equals; absl&colon;&colon;StrReplaceAll( &quot;stem:[who bought ]count &num;Noun&period; Thanks $who!&quot;, replacements)&semi; EXPECT&lowbar;EQ(&quot;Bob bought 5 Apples&period; Thanks Bob!&quot;, s)&semi;

&sol;&sol; A std&colon;&colon;vector of std&colon;&colon;pair elements can be more efficient&period; std&colon;&colon;vector&lt;std&colon;&colon;pair&lt;const absl&colon;&colon;string&lowbar;view, std&colon;&colon;string&gt;&gt; replacements&semi; replacements&period;push&lowbar;back(&lcub;&quot;&amp;&quot;, &quot;&amp;amp&semi;&quot;&rcub;)&semi; replacements&period;push&lowbar;back(&lcub;&quot;&lt;&quot;, &quot;&amp;lt&semi;&quot;&rcub;)&semi; replacements&period;push&lowbar;back(&lcub;&quot;&gt;&quot;, &quot;&amp;gt&semi;&quot;&rcub;)&semi; std&colon;&colon;string s &equals; absl&colon;&colon;StrReplaceAll(&quot;if (ptr &lt; &amp;foo)&quot;, replacements)&semi; EXPECT&lowbar;EQ(&quot;if (ptr &amp;lt&semi; &amp;amp&semi;foo)&quot;, s)&semi;

== Return Value

A new string with the replacements applied&period;

== Parameters

[cols="1,4"]
|===
| Name| Description
| *s*
| The string to search for replacements&period;
| *replacements*
| The container of key&sol;value pairs of sequences to replace&period;
|===


[.small]#Created with https://www.mrdocs.com[MrDocs]#
