<?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[StringBetween bei mehreren Möglichkeiten]]></title><description><![CDATA[<p>guten tag.<br />
Im Moment benutze ich folgende Funktion um Cookies zu extrahieren.</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>Jetzt habe ich aber folgendes Problem...<br />
Ich muss mehrere Cookies exrahieren, wobei es mehrere Möglichkeiten gibt...<br />
Hier is der Code aus dem ich sie herausextrahieren will.</p>
<pre><code>HTTP/1.1 302 Found

Date: Sun, 17 Jan 2010 11:55:30 GMT

Server: Apache/2.2.10 (Unix) PHP/5.2.8 mod_python/3.3.2-dev-20080819 Python/2.4.4

node: www11

X-Database: gde

Cache-Control: private, no-store, no-cache, must-revalidate

Pragma: no-cache

Cache-Control: no-cache=&quot;set-cookie&quot;

Set-Cookie: spcheck=1; path=/

Set-Cookie: spgdex1261708=x69e969b4-NjM4Ng-9330-61-NTYxNg; path=/

Set-Cookie: gsp=5053059; path=/; expires=Mon, 17-Jan-2011 11:55:30 GMT

location: /main.html

Vary: Accept-Encoding

Content-Length: 0

Connection: close

Content-Type: text/html; charset=utf-8
</code></pre>
<p>hat jemand ne idee wie ich das lösen könnte??? <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="😕"
    /><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/258947/stringbetween-bei-mehreren-möglichkeiten</link><generator>RSS for Node</generator><lastBuildDate>Wed, 09 Sep 2026 02:26:15 GMT</lastBuildDate><atom:link href="https://www.c-plusplus.net/forum/topic/258947.rss" rel="self" type="application/rss+xml"/><pubDate>Sun, 17 Jan 2010 12:02:02 GMT</pubDate><ttl>60</ttl><item><title><![CDATA[Reply to StringBetween bei mehreren Möglichkeiten on Sun, 17 Jan 2010 12:02:44 GMT]]></title><description><![CDATA[<p>guten tag.<br />
Im Moment benutze ich folgende Funktion um Cookies zu extrahieren.</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>Jetzt habe ich aber folgendes Problem...<br />
Ich muss mehrere Cookies exrahieren, wobei es mehrere Möglichkeiten gibt...<br />
Hier is der Code aus dem ich sie herausextrahieren will.</p>
<pre><code>HTTP/1.1 302 Found

Date: Sun, 17 Jan 2010 11:55:30 GMT

Server: Apache/2.2.10 (Unix) PHP/5.2.8 mod_python/3.3.2-dev-20080819 Python/2.4.4

node: www11

X-Database: gde

Cache-Control: private, no-store, no-cache, must-revalidate

Pragma: no-cache

Cache-Control: no-cache=&quot;set-cookie&quot;

Set-Cookie: spcheck=1; path=/

Set-Cookie: spgdex1261708=x69e969b4-NjM4Ng-9330-61-NTYxNg; path=/

Set-Cookie: gsp=5053059; path=/; expires=Mon, 17-Jan-2011 11:55:30 GMT

location: /main.html

Vary: Accept-Encoding

Content-Length: 0

Connection: close

Content-Type: text/html; charset=utf-8
</code></pre>
<p>hat jemand ne idee wie ich das lösen könnte??? <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="😕"
    /><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/1840102</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1840102</guid><dc:creator><![CDATA[*night* 0]]></dc:creator><pubDate>Sun, 17 Jan 2010 12:02:44 GMT</pubDate></item><item><title><![CDATA[Reply to StringBetween bei mehreren Möglichkeiten on Sun, 17 Jan 2010 12:05:14 GMT]]></title><description><![CDATA[<p>Öhm und wo genau liegt jetzt das Problem?</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1840105</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1840105</guid><dc:creator><![CDATA[Kóyaánasqatsi]]></dc:creator><pubDate>Sun, 17 Jan 2010 12:05:14 GMT</pubDate></item><item><title><![CDATA[Reply to StringBetween bei mehreren Möglichkeiten on Sun, 17 Jan 2010 12:26:34 GMT]]></title><description><![CDATA[<p>Das problem ist wie folgt:<br />
Wenn ich die Funktion wie folgt aufrufe:</p>
<pre><code class="language-cpp">string spgdex = StringBetween(source, &quot;Set-Cookie: spgdex1261708=&quot;, &quot;; path=/&quot;);
</code></pre>
<p>dann gibt er mir immer den gesamten teil zwischen dem cookie und dem anderen cookieblock mit...<br />
ich kanns schlecht erklären...<br />
dabei möchte ich aber nur den Teil von jedem Cookie...<br />
spgdex1261708=x69e969b4-NjM4Ng-9330-61-NTYxNg<br />
den Rest brauche ich gar nicht</p>
<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/1840117</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1840117</guid><dc:creator><![CDATA[*night* 0]]></dc:creator><pubDate>Sun, 17 Jan 2010 12:26:34 GMT</pubDate></item><item><title><![CDATA[Reply to StringBetween bei mehreren Möglichkeiten on Sun, 17 Jan 2010 13:34:08 GMT]]></title><description><![CDATA[<p>Ich verstehe nicht so ganz was du da machst, aber ich würde es folgendermaßen machen (je nachdem wie du es brauchst, kannst du dir die fnc ja umbauen):</p>
<pre><code class="language-cpp">#include &lt;iostream&gt; 
#include &lt;string&gt;

const std::string GetCookieData(const std::string Cookie)
{
	const std::size_t found_pos(Cookie.find(&quot;spgdex&quot;));
	std::string ReturnString;

	if(found_pos != std::string::npos)
		for(std::size_t i(found_pos + 6); // std::string(&quot;spgdex&quot;)::size() == 6
			Cookie[i] != ';';
			++i)
				ReturnString.push_back(Cookie[i]);

	return ReturnString;
}

int main() 
{
	const std::string Cookie = GetCookieData(&quot;Set-Cookie: spgdex1261708=x69e969b4-NjM4Ng-9330-61-NTYxNg; path=/ &quot;);

	Cookie;

	std::cin.get();
}
</code></pre>
]]></description><link>https://www.c-plusplus.net/forum/post/1840159</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1840159</guid><dc:creator><![CDATA[Kóyaánasqatsi]]></dc:creator><pubDate>Sun, 17 Jan 2010 13:34:08 GMT</pubDate></item><item><title><![CDATA[Reply to StringBetween bei mehreren Möglichkeiten on Sun, 17 Jan 2010 13:50:27 GMT]]></title><description><![CDATA[<p>danke dir <img
      src="https://www.c-plusplus.net/forum/plugins/nodebb-plugin-emoji/emoji/emoji-one/1f44d.png?v=ab1pehoraso"
      class="not-responsive emoji emoji-emoji-one emoji--thumbs_up"
      title=":+1:"
      alt="👍"
    /><br />
dass hast du extrem gut gelöst! Auf so etwas wär ich nie selber gekommen <img
      src="https://www.c-plusplus.net/forum/plugins/nodebb-plugin-emoji/emoji/emoji-one/1f44d.png?v=ab1pehoraso"
      class="not-responsive emoji emoji-emoji-one emoji--thumbs_up"
      title=":+1:"
      alt="👍"
    /><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/1840170</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1840170</guid><dc:creator><![CDATA[*night* 0]]></dc:creator><pubDate>Sun, 17 Jan 2010 13:50:27 GMT</pubDate></item></channel></rss>