<?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[String zwischen 2 anderen Strings]]></title><description><![CDATA[<p>heyho!<br />
kennt jemand eine Funktion, mit der ich einen String zwischen zwei anderen anderen Strings raussuchen kann.<br />
Nach dem Motto:</p>
<pre><code class="language-cpp">string mystring = &quot;&lt;img&gt;heyho&lt;/img&gt;&quot;;
string start = &quot;&lt;img&gt;&quot;;
string ende = &quot;&lt;/img&gt;&quot;;
string ergebnis = Stringbetween(mystring,start, ende); // das ergebnis sollte //'heyho' sein
</code></pre>
<p>mfg<br />
<a class="plugin-mentions-user plugin-mentions-a" href="https://www.c-plusplus.net/forum/uid/8811">@night</a>@</p>
]]></description><link>https://www.c-plusplus.net/forum/topic/257387/string-zwischen-2-anderen-strings</link><generator>RSS for Node</generator><lastBuildDate>Thu, 10 Sep 2026 06:25:32 GMT</lastBuildDate><atom:link href="https://www.c-plusplus.net/forum/topic/257387.rss" rel="self" type="application/rss+xml"/><pubDate>Sun, 27 Dec 2009 19:51:04 GMT</pubDate><ttl>60</ttl><item><title><![CDATA[Reply to String zwischen 2 anderen Strings on Sun, 27 Dec 2009 19:52:21 GMT]]></title><description><![CDATA[<p>heyho!<br />
kennt jemand eine Funktion, mit der ich einen String zwischen zwei anderen anderen Strings raussuchen kann.<br />
Nach dem Motto:</p>
<pre><code class="language-cpp">string mystring = &quot;&lt;img&gt;heyho&lt;/img&gt;&quot;;
string start = &quot;&lt;img&gt;&quot;;
string ende = &quot;&lt;/img&gt;&quot;;
string ergebnis = Stringbetween(mystring,start, ende); // das ergebnis sollte //'heyho' sein
</code></pre>
<p>mfg<br />
<a class="plugin-mentions-user plugin-mentions-a" href="https://www.c-plusplus.net/forum/uid/8811">@night</a>@</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1828636</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1828636</guid><dc:creator><![CDATA[*night* 0]]></dc:creator><pubDate>Sun, 27 Dec 2009 19:52:21 GMT</pubDate></item><item><title><![CDATA[Reply to String zwischen 2 anderen Strings on Sun, 27 Dec 2009 20:26:25 GMT]]></title><description><![CDATA[<p>wenn du evtl eindeutige trenner nehmen könntest kannste mit string.find() das zeichen von anfang an suchen mit und mit string.rfind() nach dem letzen vorkommen des Zeichens suchen und dann schneiden.<br />
Obwohl es ja so geht bei dir . Erste zeichen wäre &gt; und letzte wäre &lt;<br />
wenn ich mich nicht täusche.</p>
<p>vieleicht hilft die das weiter besonder die erste Seite. Mir half sie <img
      src="https://www.c-plusplus.net/forum/plugins/nodebb-plugin-emoji/emoji/emoji-one/1f642.png?v=ab1pehoraso"
      class="not-responsive emoji emoji-emoji-one emoji--slightly_smiling_face"
      title=":-)"
      alt="🙂"
    /><br />
<a href="http://www.mathematik.uni-muenchen.de/~spann/vorlesungen/c++/ws09/inf4.pdf" rel="nofollow">http://www.mathematik.uni-muenchen.de/~spann/vorlesungen/c++/ws09/inf4.pdf</a></p>
<p>mfg Michael</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1828641</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1828641</guid><dc:creator><![CDATA[Brusko]]></dc:creator><pubDate>Sun, 27 Dec 2009 20:26:25 GMT</pubDate></item><item><title><![CDATA[Reply to String zwischen 2 anderen Strings on Sun, 27 Dec 2009 20:03:29 GMT]]></title><description><![CDATA[<p>Die Methode substr von einem string?</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1828642</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1828642</guid><dc:creator><![CDATA[flohh]]></dc:creator><pubDate>Sun, 27 Dec 2009 20:03:29 GMT</pubDate></item><item><title><![CDATA[Reply to String zwischen 2 anderen Strings on Sun, 27 Dec 2009 20:10:36 GMT]]></title><description><![CDATA[<blockquote>
<p>und dann schneiden.</p>
</blockquote>
<p>Wie schneiden <img
      src="https://www.c-plusplus.net/forum/plugins/nodebb-plugin-emoji/emoji/emoji-one/1f615.png?v=ab1pehoraso"
      class="not-responsive emoji emoji-emoji-one emoji--confused_face"
      title=":confused:"
      alt="😕"
    /></p>
]]></description><link>https://www.c-plusplus.net/forum/post/1828645</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1828645</guid><dc:creator><![CDATA[*night* 0]]></dc:creator><pubDate>Sun, 27 Dec 2009 20:10:36 GMT</pubDate></item><item><title><![CDATA[Reply to String zwischen 2 anderen Strings on Sun, 27 Dec 2009 20:27:01 GMT]]></title><description><![CDATA[<p>substr schreibt doch entweder ab einen punkt den Rest oder ab einen Punkt eine bestimmte anzahl von zeichen.<br />
Wenn er das in vorfeld immer weis kann er das ja auch so machen, Ich würde aber wohl eher rausfiltern.</p>
<p>mfg Michael</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1828647</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1828647</guid><dc:creator><![CDATA[Brusko]]></dc:creator><pubDate>Sun, 27 Dec 2009 20:27:01 GMT</pubDate></item><item><title><![CDATA[Reply to String zwischen 2 anderen Strings on Sun, 27 Dec 2009 20:22:27 GMT]]></title><description><![CDATA[<pre><code class="language-cpp">if (bufferstring.find(&quot;ICY-META&quot;) != string::npos)
             {
              big_string = bufferstring.size(); // größe ermitteln
              pos_one = bufferstring.find(&quot;'&quot;); // estes zeichen finden position ermitten
              bufferstring.erase(0,pos_one + 1); // Abschneiden teil string von vorne
              pos_two = bufferstring.find(&quot;;&quot;); // zweites zeichen suchen 
              bufferstring.erase(pos_two - 1);  // rest abschneiden
              pthread_mutex_lock (&amp;radiomutex);
              interpret_title = bufferstring;
              pthread_mutex_unlock (&amp;radiomutex);
             }
</code></pre>
<p>hier mal ein beispiel der einen aus einem stream den titel rausgibt der stream sieht so aus</p>
<pre><code class="language-cpp"><a class="plugin-mentions-user plugin-mentions-a" href="https://www.c-plusplus.net/forum/uid/6765">@I</a> ICY-META: StreamTitle='RAMMSTEIN - DU RIECHST SO GUT';StreamUrl='http://www.dieneue1077.de';
</code></pre>
<p>und das ergebnis so</p>
<pre><code class="language-cpp">RAMMSTEIN - DU RIECHST SO GUT
</code></pre>
<p>es kann der string immer unterschiedlich lang sein es wird passend geschnitten<br />
habe mal den code nacherklärt</p>
<p>mfg Michael</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1828649</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1828649</guid><dc:creator><![CDATA[Brusko]]></dc:creator><pubDate>Sun, 27 Dec 2009 20:22:27 GMT</pubDate></item><item><title><![CDATA[Reply to String zwischen 2 anderen Strings on Sun, 27 Dec 2009 20:27:47 GMT]]></title><description><![CDATA[<pre><code class="language-cpp">#include &lt;iostream&gt;
#include &lt;string&gt;

std::string StringBetween(const std::string&amp; input, const std::string&amp; left, const std::string&amp; right)
{
	size_t posLeft, posRight;

	posLeft = input.find(left);
	posRight = input.find(right);

	if (posLeft == std::string::npos || posRight == std::string::npos)
	{
		return &quot;&quot;; // Nicht gefunden
	}

	posLeft += left.length();

	return input.substr(posLeft, input.length() - right.length() - left.length());
}

int main()
{
	std::cout &lt;&lt; &quot;'&quot; &lt;&lt; StringBetween(&quot;&lt;img&gt;The image stuff...&lt;/img&gt;&quot;, &quot;&lt;img&gt;&quot;, &quot;&lt;/img&gt;&quot;) &lt;&lt; &quot;'&quot; &lt;&lt; std::endl;

	return 0;
}
</code></pre>
]]></description><link>https://www.c-plusplus.net/forum/post/1828651</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1828651</guid><dc:creator><![CDATA[uuuuuuuuuuuuuuuu]]></dc:creator><pubDate>Sun, 27 Dec 2009 20:27:47 GMT</pubDate></item><item><title><![CDATA[Reply to String zwischen 2 anderen Strings on Tue, 29 Dec 2009 09:43:01 GMT]]></title><description><![CDATA[<p>es gibt da noch ein Problem...</p>
<pre><code class="language-cpp">string mystring = &quot;&lt;img&gt;heyho&lt;/img&gt;irgendeintext&quot;;
    string ergebnis = StringBetween(mystring, &quot;&lt;img&gt;&quot;, &quot;&lt;/img&gt;&quot;);
    cout &lt;&lt; ergebnis &lt;&lt; endl;
    system(&quot;pause&quot;);
</code></pre>
<p>Der Rückgabewert ist: heyho&lt;/img&gt;irgendeintext<br />
Irgendwas ist da falsch...<br />
mfg<br />
<a class="plugin-mentions-user plugin-mentions-a" href="https://www.c-plusplus.net/forum/uid/8811">@night</a>@</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1829186</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1829186</guid><dc:creator><![CDATA[*night* 0]]></dc:creator><pubDate>Tue, 29 Dec 2009 09:43:01 GMT</pubDate></item><item><title><![CDATA[Reply to String zwischen 2 anderen Strings on Tue, 29 Dec 2009 09:53:42 GMT]]></title><description><![CDATA[<p>uuuuuuuuuuuuuuuu schrieb:</p>
<blockquote>
<pre><code class="language-cpp">#include &lt;iostream&gt;
#include &lt;string&gt;

std::string StringBetween(const std::string&amp; input, const std::string&amp; left, const std::string&amp; right)
{
	size_t posLeft, posRight;

	posLeft = input.find(left);
	posRight = input.find(right);

	if (posLeft == std::string::npos || posRight == std::string::npos)
	{
		return &quot;&quot;; // Nicht gefunden
	}

	posLeft += left.length();

	return input.substr(posLeft, input.length() - right.length() - left.length());
}

int main()
{
	std::cout &lt;&lt; &quot;'&quot; &lt;&lt; StringBetween(&quot;&lt;img&gt;The image stuff...&lt;/img&gt;&quot;, &quot;&lt;img&gt;&quot;, &quot;&lt;/img&gt;&quot;) &lt;&lt; &quot;'&quot; &lt;&lt; std::endl;

	return 0;
}
</code></pre>
</blockquote>
<p>Du hast das posRight nicht verarbeitet. Und was ist, wenn posRight &lt; posLeft ist? Also z. B. in &quot;&lt;/img&gt;foo&lt;img&gt;&quot;.</p>
<p>Auf der anderen Seite hat <a class="plugin-mentions-user plugin-mentions-a" href="https://www.c-plusplus.net/forum/uid/8811">@night</a>@ ja jetzt den Ansatz. Das Bugfixing sollte nicht mehr so schwer sein.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1829195</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1829195</guid><dc:creator><![CDATA[tntnet]]></dc:creator><pubDate>Tue, 29 Dec 2009 09:53:42 GMT</pubDate></item><item><title><![CDATA[Reply to String zwischen 2 anderen Strings on Tue, 29 Dec 2009 11:18:30 GMT]]></title><description><![CDATA[<p>heyho.<br />
ich hab jetzt mal versucht posRight negativ abzutrennen.</p>
<pre><code class="language-cpp">string ergebnis2 = ergebnis1.substr((-posRight), 1);
</code></pre>
<p>Nur mal so zum probieren. Die idde hab ich von <a href="http://www.google.de/search?hl=de&amp;q=string.substr&amp;btnG=Suche&amp;meta=lr%3Dlang_de&amp;cts=1262082208845&amp;aq=f&amp;oq=" rel="nofollow">hier</a>(1.Link--&gt;aus irgendeinem Grund kann man das net verlinken -.-)<br />
Aber auf diese Weise stürzt entweder das Programm ab, oder der Compiler will den Code nicht kompillieren...<br />
Gibt es noch iregendeine Möglichkeit von der anderen Seite des Strings Buchstaben abzuschneiden???<br />
mfg<br />
<a class="plugin-mentions-user plugin-mentions-a" href="https://www.c-plusplus.net/forum/uid/8811">@night</a>@</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1829203</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1829203</guid><dc:creator><![CDATA[*night* 0]]></dc:creator><pubDate>Tue, 29 Dec 2009 11:18:30 GMT</pubDate></item><item><title><![CDATA[Reply to String zwischen 2 anderen Strings on Tue, 29 Dec 2009 12:14:11 GMT]]></title><description><![CDATA[<p>ich habs jetzt hingekriegt...</p>
<pre><code class="language-cpp">string StringBetween(const string&amp; input, const string&amp; left, const string&amp; right)
{
    size_t posLeft, posRight;

    posLeft = input.find(left);
    posRight = input.find(right);

    if (posLeft == string::npos || posRight == string::npos)
    {
        return &quot;&quot;; // Nicht gefunden
    }

    posLeft += left.length();
    posRight += right.length();
    string ergebnis1 = input.substr(posLeft, input.length() - right.length() - left.length());
    int formel = (input.find(right) - posLeft);
    string ergebnis2 = ergebnis1.substr(0, formel);
    return ergebnis2;
}
</code></pre>
<p>mfg<br />
<a class="plugin-mentions-user plugin-mentions-a" href="https://www.c-plusplus.net/forum/uid/8811">@night</a>@</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1829252</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1829252</guid><dc:creator><![CDATA[*night* 0]]></dc:creator><pubDate>Tue, 29 Dec 2009 12:14:11 GMT</pubDate></item><item><title><![CDATA[Reply to String zwischen 2 anderen Strings on Tue, 29 Dec 2009 13:25:30 GMT]]></title><description><![CDATA[<pre><code class="language-cpp">string string_to_cut (string bufferstring , string begin , string end , int number_of_a , int number_of_b)
      {
       int big_string , pos_one , pos_two;
       big_string = bufferstring.size();
       if (bufferstring.find(begin) != string::npos)
         {pos_one = bufferstring.find(begin);bufferstring.erase(0,pos_one+number_of_a);}
       else {bufferstring.erase(); errorwrite(&quot;string begin&quot;,&quot;string_to_cut&quot;);}
       if (bufferstring.find(end) != string::npos)
         {pos_two = bufferstring.find(end);bufferstring.erase(pos_two-number_of_b);}
       else {bufferstring.erase(); errorwrite(&quot;string end&quot;,&quot;string_to_cut&quot;);}
       begin.erase();
       end.erase();
       return bufferstring;
      }
</code></pre>
<p>spricht doch auch nichts gegen oder ?<br />
klappt zumindest</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1829304</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1829304</guid><dc:creator><![CDATA[Nurmalso]]></dc:creator><pubDate>Tue, 29 Dec 2009 13:25:30 GMT</pubDate></item></channel></rss>