<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0"><channel><title><![CDATA[find and replace im String]]></title><description><![CDATA[<p>Hallo,</p>
<p>ich versuche innerhalb eines strings '\n' durch &quot;&lt;br&gt;&quot; zu ersetzen muss man sich diese replace-funktoin selbst schreiben oder gibt es eine Möglichkeit STL-algorithmen zu nutzen?</p>
]]></description><link>https://www.c-plusplus.net/forum/topic/146216/find-and-replace-im-string</link><generator>RSS for Node</generator><lastBuildDate>Thu, 03 Sep 2026 14:13:59 GMT</lastBuildDate><atom:link href="https://www.c-plusplus.net/forum/topic/146216.rss" rel="self" type="application/rss+xml"/><pubDate>Fri, 05 May 2006 11:23:18 GMT</pubDate><ttl>60</ttl><item><title><![CDATA[Reply to find and replace im String on Fri, 05 May 2006 11:23:18 GMT]]></title><description><![CDATA[<p>Hallo,</p>
<p>ich versuche innerhalb eines strings '\n' durch &quot;&lt;br&gt;&quot; zu ersetzen muss man sich diese replace-funktoin selbst schreiben oder gibt es eine Möglichkeit STL-algorithmen zu nutzen?</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1051448</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1051448</guid><dc:creator><![CDATA[templäd]]></dc:creator><pubDate>Fri, 05 May 2006 11:23:18 GMT</pubDate></item><item><title><![CDATA[Reply to find and replace im String on Fri, 05 May 2006 11:25:16 GMT]]></title><description><![CDATA[<p>Schau mal in die String Algo Boost-Library rein, da gibts was passendes:<br />
<a href="http://www.boost.org/doc/html/string_algo/usage.html#id2742991" rel="nofollow">http://www.boost.org/doc/html/string_algo/usage.html#id2742991</a></p>
]]></description><link>https://www.c-plusplus.net/forum/post/1051450</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1051450</guid><dc:creator><![CDATA[Artchi]]></dc:creator><pubDate>Fri, 05 May 2006 11:25:16 GMT</pubDate></item><item><title><![CDATA[Reply to find and replace im String on Fri, 05 May 2006 11:27:15 GMT]]></title><description><![CDATA[<p>Mit den Algorithmen könnte das etwas schwer werden (weil die Sequenz bei der Ersetzung länger wird - und ein Algorithmus kann/darf nicht auf die interne Datenstruktur zugreifen). Aber Strings bieten die Methoden find() (sucht eine bestimmte Sequenz) und replace (ersetzt einen Zeichenblock), die du in einer Schleife aufrufen kannst:</p>
<pre><code class="language-cpp">while((p=str.find('\n'))!=string::npos)
  str.replace(p,p+1,&quot;&lt;br&gt;&quot;);
</code></pre>
]]></description><link>https://www.c-plusplus.net/forum/post/1051451</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1051451</guid><dc:creator><![CDATA[CStoll]]></dc:creator><pubDate>Fri, 05 May 2006 11:27:15 GMT</pubDate></item><item><title><![CDATA[Reply to find and replace im String on Fri, 05 May 2006 11:35:12 GMT]]></title><description><![CDATA[<p>Perfekt! Danke!</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1051454</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1051454</guid><dc:creator><![CDATA[templäd]]></dc:creator><pubDate>Fri, 05 May 2006 11:35:12 GMT</pubDate></item><item><title><![CDATA[Reply to find and replace im String on Fri, 05 May 2006 12:32:44 GMT]]></title><description><![CDATA[<p>Beim replace-Aufruf sollte es wohl &quot;1&quot; statt &quot;p+1&quot; heissen...</p>
<pre><code class="language-cpp">void replace( std::string&amp; str, char what, std::string const&amp; with )
{
  string::size_type const offset = with.length()-1;
  string::size_type pos = -offset;
  while ((pos = str.find(what, pos+offset)) != string::npos) {
    str.replace(pos, 1, with);
  }
}
</code></pre>
]]></description><link>https://www.c-plusplus.net/forum/post/1051497</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1051497</guid><dc:creator><![CDATA[finix]]></dc:creator><pubDate>Fri, 05 May 2006 12:32:44 GMT</pubDate></item></channel></rss>