<?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 in Einzelteile zerlegen]]></title><description><![CDATA[<p>Hallo!</p>
<p>Wie kann ich einen String in seine Bestandteile Zerlegen?<br />
Beispielstring: &quot;bellt [VVFIN person=3 number=sg mood=ind tense=pres]&quot;.<br />
Er ist so aufgebaut: \w+\s+\[\w+\s+\([\w\d]+=[\w\d]+)*\]<br />
\w = Buchstaben, \s = Whitespaces, also Leerzeichen, Tabulator usw., \d = Ziffer, + = mind. 1mal, * = 0 oder öfter</p>
<p>Ich habe keine Ahnung wie das in C++ gehen soll.<br />
In Perl würde es so aussehen:</p>
<pre><code>my $line = &quot;bellt	[VVFIN person=3 number=sg mood=ind tense=pres]&quot;;
my ($word, $pos, $attrs) = $line =~ /^(\w+)\s+\[(\w+)\s+(.*)\]/;
my %attrs = map m/(\w+)=(\w+)/, split /\s+/, $attrs;
</code></pre>
<p>Grüße, pktm</p>
<p>PS: ich erwarte nicht, dass ihr meine Arbeit macht, aber ein Stoß in die richtige Richtung wär toll <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="🙂"
    /></p>
]]></description><link>https://www.c-plusplus.net/forum/topic/211580/string-in-einzelteile-zerlegen</link><generator>RSS for Node</generator><lastBuildDate>Wed, 14 Oct 2026 06:26:07 GMT</lastBuildDate><atom:link href="https://www.c-plusplus.net/forum/topic/211580.rss" rel="self" type="application/rss+xml"/><pubDate>Thu, 24 Apr 2008 18:05:42 GMT</pubDate><ttl>60</ttl><item><title><![CDATA[Reply to String in Einzelteile zerlegen on Thu, 24 Apr 2008 18:05:42 GMT]]></title><description><![CDATA[<p>Hallo!</p>
<p>Wie kann ich einen String in seine Bestandteile Zerlegen?<br />
Beispielstring: &quot;bellt [VVFIN person=3 number=sg mood=ind tense=pres]&quot;.<br />
Er ist so aufgebaut: \w+\s+\[\w+\s+\([\w\d]+=[\w\d]+)*\]<br />
\w = Buchstaben, \s = Whitespaces, also Leerzeichen, Tabulator usw., \d = Ziffer, + = mind. 1mal, * = 0 oder öfter</p>
<p>Ich habe keine Ahnung wie das in C++ gehen soll.<br />
In Perl würde es so aussehen:</p>
<pre><code>my $line = &quot;bellt	[VVFIN person=3 number=sg mood=ind tense=pres]&quot;;
my ($word, $pos, $attrs) = $line =~ /^(\w+)\s+\[(\w+)\s+(.*)\]/;
my %attrs = map m/(\w+)=(\w+)/, split /\s+/, $attrs;
</code></pre>
<p>Grüße, pktm</p>
<p>PS: ich erwarte nicht, dass ihr meine Arbeit macht, aber ein Stoß in die richtige Richtung wär toll <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="🙂"
    /></p>
]]></description><link>https://www.c-plusplus.net/forum/post/1497707</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1497707</guid><dc:creator><![CDATA[pktm]]></dc:creator><pubDate>Thu, 24 Apr 2008 18:05:42 GMT</pubDate></item><item><title><![CDATA[Reply to String in Einzelteile zerlegen on Thu, 24 Apr 2008 18:14:42 GMT]]></title><description><![CDATA[<p>Schau dir mal <a href="http://www.cppreference.com/cppstring/find.html" rel="nofollow">find ()</a> und <a href="http://www.cppreference.com/cppstring/substr.html" rel="nofollow">substr ()</a>, sowie die weiteren Stringfunktion an.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1497713</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1497713</guid><dc:creator><![CDATA[basti33]]></dc:creator><pubDate>Thu, 24 Apr 2008 18:14:42 GMT</pubDate></item><item><title><![CDATA[Reply to String in Einzelteile zerlegen on Thu, 24 Apr 2008 18:23:57 GMT]]></title><description><![CDATA[<p>basti33 schrieb:</p>
<blockquote>
<p>Schau dir mal <a href="http://www.cppreference.com/cppstring/find.html" rel="nofollow">find ()</a> und <a href="http://www.cppreference.com/cppstring/substr.html" rel="nofollow">substr ()</a>, sowie die weiteren Stringfunktion an.</p>
</blockquote>
<p>Ja, die hab ich schon.<br />
Aber wenn ich mit einer Schleife über alle Positionen des Strings iteriere, dann muss ich mir in einer Reihe von boolschen Variablen merken, was ich schon gefunden habe, und was nicht, damit ich die einzelnen Bestandteile richtig extrahieren kann.<br />
Mein Plan in Stichworten &amp; Pseudocode:</p>
<pre><code>string s = &quot;w  [pos attr=val]&quot;; // eingabe

	string w = &quot;&quot;; // Zwischenspeicher für zu lesendes Wort.
	string p = &quot;&quot;; // Zwischenspeicher für zu lesendes POS-Tag.
	string a = &quot;&quot;; // Zwischenspeicher für zu lesendes Attribut.

        // merken, wo wir sind
	bool reading_word	= true;
	bool reading_pos	= true;
	bool reading_attr	= true;

	for( unsigned int i = 0; i &lt; line.length(); i++ ) {
		// gaaaanz viele Verzweigungen, je nach dem, welcher Abschnitt gerade dran ist und wo was angahangen werden soll.
		// z.B: so:
		if( reading_word ) {
			if( !(line.at(i) == &quot; &quot; || line.at(i) == &quot;\t&quot;) ) {
				reading_word = false; // wort ist hier zuende
			}else{
				w.append(line.at(i));
			}
		}else if( reading_pos ){

		}else if ( reading_attr ) {
		}else{

		}
	}
</code></pre>
<p>Aber ist das nicht igrnendwie total wahnwitzig? Das geht bestimmt auch anders... <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="🙂"
    /></p>
<p>Edit: Die andere Variante wäre, &quot;]&quot; abzuschneiden, bei allen Whitespaves aufzuspalten, dann die einzelnen Elemente zu untersuchen und bei [x die Klammer ab zu machen und x als POS zu speichern, bei allen &quot;=&quot;-beinhaltenden bei &quot;=&quot; zu splitten und die Attribut-Wert-Paare zu speichern und was übrig ist (1 Element) ist das Wort.<br />
Aber das sieht für mich irgendwie dreckig aus, und nach viel zu viel Arbeit.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1497715</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1497715</guid><dc:creator><![CDATA[pktm]]></dc:creator><pubDate>Thu, 24 Apr 2008 18:23:57 GMT</pubDate></item><item><title><![CDATA[Reply to String in Einzelteile zerlegen on Thu, 24 Apr 2008 18:35:55 GMT]]></title><description><![CDATA[<p>boost bietet dir eine Regex-Klasse die so, oder leicht verändert auch in den Standard einfließen wird.</p>
<p>Mit etwas Glück hat dein Compiler dies schon im Rahmen des TR1 implentiert.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1497723</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1497723</guid><dc:creator><![CDATA[The-Kenny]]></dc:creator><pubDate>Thu, 24 Apr 2008 18:35:55 GMT</pubDate></item><item><title><![CDATA[Reply to String in Einzelteile zerlegen on Thu, 24 Apr 2008 18:39:20 GMT]]></title><description><![CDATA[<p>The-Kenny schrieb:</p>
<blockquote>
<p>Mit etwas Glück hat dein Compiler dies schon im Rahmen des TR1 implentiert.</p>
</blockquote>
<p>Scheint nicht so. Aber ich versuche gerade boost zu installieren.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1497725</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1497725</guid><dc:creator><![CDATA[pktm]]></dc:creator><pubDate>Thu, 24 Apr 2008 18:39:20 GMT</pubDate></item></channel></rss>