<?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[Schon wieder StringBetween(string.substr())...]]></title><description><![CDATA[<p>guten morgen.<br />
ich versuche gerade die Funnktion StringBetween, so umzuschreiben, dass ich damit auch mehrere Wörter &quot;herausholen&quot; kann.<br />
beispiel:<br />
Ich hol mir den Source von <a href="http://google.de" rel="nofollow">google.de</a> per WSA und möchte anschliessend alle Cookies extrahieren.</p>
<pre><code>Content-Type: text/html; charset=UTF-8

Set-Cookie:PREF=ID=dc0ae71c55dd1967:TM=1262770468:LM=1262770468:S=Lg6uv9GIPqdDK74-;expires=Fri, 06-Jan-2012 09:34:28 GMT; path=/; domain=.google.de 

Set-Cookie: NID=30=Puj4EOco_v8gq6AokQ5KFZrxjfnmt46E2Hx023IRHfOxfUJEvmrN19F9p0EsGswuZB0JLYminJlPK0bl9PdzeyQuKu2qB-GAjEgmO_Wy-euO2iWpO-8sVknNN0m9h-i5; expires=Thu, 08-Jul-2010 09:34:28 GMT; path=/; domain=.google.de; HttpOnly
</code></pre>
<p>Jetzt möchte ich folgendes erreichen.<br />
Ich möchte beide Namen samt Inhalt von den Cookies haben.<br />
Hier ist meine Funktion:</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>Leider schaffe ich es nicht immer den Teil, den ich schon behandelt habe, per string.substr() rauszuschneiden...<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/topic/258061/schon-wieder-stringbetween-string-substr</link><generator>RSS for Node</generator><lastBuildDate>Wed, 09 Sep 2026 15:52:22 GMT</lastBuildDate><atom:link href="https://www.c-plusplus.net/forum/topic/258061.rss" rel="self" type="application/rss+xml"/><pubDate>Wed, 06 Jan 2010 10:08:14 GMT</pubDate><ttl>60</ttl><item><title><![CDATA[Reply to Schon wieder StringBetween(string.substr())... on Wed, 06 Jan 2010 10:08:56 GMT]]></title><description><![CDATA[<p>guten morgen.<br />
ich versuche gerade die Funnktion StringBetween, so umzuschreiben, dass ich damit auch mehrere Wörter &quot;herausholen&quot; kann.<br />
beispiel:<br />
Ich hol mir den Source von <a href="http://google.de" rel="nofollow">google.de</a> per WSA und möchte anschliessend alle Cookies extrahieren.</p>
<pre><code>Content-Type: text/html; charset=UTF-8

Set-Cookie:PREF=ID=dc0ae71c55dd1967:TM=1262770468:LM=1262770468:S=Lg6uv9GIPqdDK74-;expires=Fri, 06-Jan-2012 09:34:28 GMT; path=/; domain=.google.de 

Set-Cookie: NID=30=Puj4EOco_v8gq6AokQ5KFZrxjfnmt46E2Hx023IRHfOxfUJEvmrN19F9p0EsGswuZB0JLYminJlPK0bl9PdzeyQuKu2qB-GAjEgmO_Wy-euO2iWpO-8sVknNN0m9h-i5; expires=Thu, 08-Jul-2010 09:34:28 GMT; path=/; domain=.google.de; HttpOnly
</code></pre>
<p>Jetzt möchte ich folgendes erreichen.<br />
Ich möchte beide Namen samt Inhalt von den Cookies haben.<br />
Hier ist meine Funktion:</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>Leider schaffe ich es nicht immer den Teil, den ich schon behandelt habe, per string.substr() rauszuschneiden...<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/1833487</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1833487</guid><dc:creator><![CDATA[*night* 0]]></dc:creator><pubDate>Wed, 06 Jan 2010 10:08:56 GMT</pubDate></item><item><title><![CDATA[Reply to Schon wieder StringBetween(string.substr())... on Wed, 06 Jan 2010 10:28:19 GMT]]></title><description><![CDATA[<p>Wenn ich mich nicht täusche, ungetestet:</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();

    string ergebnis1 = input.substr(posLeft, posRight - posLeft);
    return ergebnis1;
}
</code></pre>
]]></description><link>https://www.c-plusplus.net/forum/post/1833497</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1833497</guid><dc:creator><![CDATA[Fellhuhn]]></dc:creator><pubDate>Wed, 06 Jan 2010 10:28:19 GMT</pubDate></item><item><title><![CDATA[Reply to Schon wieder StringBetween(string.substr())... on Wed, 06 Jan 2010 11:51:15 GMT]]></title><description><![CDATA[<p>Zwar hat deinen Antwort iwie keinen Sinn, aber das Problem hat sich ohnehin gelöst^^<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/1833550</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1833550</guid><dc:creator><![CDATA[*night* 0]]></dc:creator><pubDate>Wed, 06 Jan 2010 11:51:15 GMT</pubDate></item><item><title><![CDATA[Reply to Schon wieder StringBetween(string.substr())... on Wed, 06 Jan 2010 12:14:12 GMT]]></title><description><![CDATA[<p>Hat sie nicht? Wäre mir neu. Naja.</p>
<p>EDIT: Hab meine Antwort mal getestet: Funktioniert.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1833572</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1833572</guid><dc:creator><![CDATA[Fellhuhn]]></dc:creator><pubDate>Wed, 06 Jan 2010 12:14:12 GMT</pubDate></item></channel></rss>