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

Replaces character sequences within a given string with replacements provided within an initializer list of key&sol;value pairs&period;

== Synopsis

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

[source,cpp,subs="verbatim,replacements,macros,-callouts"]
----
&lsqb;&lsqb;nodiscard&rsqb;&rsqb;
std::string
StrReplaceAll(
    std::string&lowbar;view s,
    std::initializer&lowbar;list&lt;std::pair&lt;std::string&lowbar;view, std::string&lowbar;view&gt;&gt; replacements);
----

== Description

Candidate replacements are considered in order as they occur within the string, with earlier matches taking precedence, and longer matches taking precedence for candidates starting at the same position in the string&period; Once a substitution is made, the replaced text is not considered for any further substitutions&period;

Example&colon;

std&colon;&colon;string s &equals; absl&colon;&colon;StrReplaceAll( &quot;stem:[who bought ]count &num;Noun&period; Thanks $who!&quot;, &lcub;&lcub;&quot;$count&quot;, absl&colon;&colon;StrCat(5)&rcub;, &lcub;&quot;$who&quot;, &quot;Bob&quot;&rcub;, &lcub;&quot;&num;Noun&quot;, &quot;Apples&quot;&rcub;&rcub;)&semi; EXPECT&lowbar;EQ(&quot;Bob bought 5 Apples&period; Thanks Bob!&quot;, s)&semi;

== Return Value

A new string with the replacements applied&period;

[NOTE]
====
The return value https://en.cppreference.com/cpp/language/attributes/nodiscard[should not be discarded^].
====
== Parameters

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


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