<?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[Boost::Regex Frage]]></title><description><![CDATA[<p>hi,<br />
ich weiss nicht ob ich hier richtig bin...<br />
ich hab einen kleinen regex ausdruck definiert...<br />
warum funzt folgender ausdruck für den string test in der main nicht:</p>
<pre><code class="language-cpp">boost::regex rxSenderEmail
(
	&quot;(aRecip\&quot; title=\&quot;)&quot;  // intro
	&quot;( ([az]|[AZ]|[09]|\\@|\\.)* )&quot; // alles dazwischen + weitere
	&quot;(\&quot;)&quot;                 // outtro
);
</code></pre>
<p>was ist der unterschied zw. resMatch[ 0 ]; und resMatch[ 5 ]; bzw. *(resMatch[ 0 ].second) ...ist in der boost doku nicht verständlich;/</p>
<p>so gehts:</p>
<pre><code class="language-cpp">bool check_SenderEmail(const string strBuffer)
{
	boost::regex rxSenderEmail
	(
		&quot;aRecip\&quot; title=\&quot;&quot;       // intro
		&quot;(&quot;
		&quot;\\d|\\l|\\u|&quot;          // digits, lowers, uppers
		&quot;[\\?\\./=@%&amp;_-]&quot;       // extra chars in an email addy
		&quot;)*&quot;
		&quot;\&quot;&quot;                      // must end with inverted commas
	);

	typedef std::string::const_iterator str_cit;

	str_cit sciStart = strBuffer.begin();           // 1st offset of file or buffer
        str_cit sciEnd = strBuffer.end();             // last offset of file or buffer

        boost::match_results&lt; str_cit &gt; resMatch;
	boost::match_flag_type flgMatch = boost::match_default;

	string strMatch;

	if(regex_search(sciStart, sciEnd, resMatch, rxSenderEmail, flgMatch)) {
		strMatch = resMatch[ 0 ];
		strMatch.erase(0, 15);
		strMatch.erase(strMatch.length() - 1, 1);
		cout &lt;&lt; strMatch.c_str() &lt;&lt; endl;
		return true;
	}

	else return false;           // no match found
}

int main()
{
	string test(&quot;&lt;TD valign=\&quot;middle\&quot; align=\&quot;left\&quot;&gt;&lt;FONT color=\&quot;#000000\&quot; size=\&quot;2\&quot;&gt;&amp;nbsp;&lt;A href=\&quot;./?cmd=editrecipient&amp;Index=-1\&quot; class=\&quot;aRecip\&quot; title=\&quot;Max.Mustermann@klu.ac.at\&quot;&gt;&lt;FONT SIZE='2' COLOR=black&gt;Max Mustermann&lt;/FONT&gt;&lt;/A&gt;&lt;/FONT&gt;&lt;/TD&gt;&quot;);
	cout &lt;&lt; check_SenderEmail(test) &lt;&lt; endl;
        cin.get();
        return 0;
}
</code></pre>
<p>wie kann ich dem gematchen string bekommen ohne mit string::clear zu arbeiten? will also den string zwischen intro und outtro bekommen...</p>
]]></description><link>https://www.c-plusplus.net/forum/topic/158395/boost-regex-frage</link><generator>RSS for Node</generator><lastBuildDate>Wed, 09 Sep 2026 18:42:54 GMT</lastBuildDate><atom:link href="https://www.c-plusplus.net/forum/topic/158395.rss" rel="self" type="application/rss+xml"/><pubDate>Tue, 05 Sep 2006 04:17:39 GMT</pubDate><ttl>60</ttl><item><title><![CDATA[Reply to Boost::Regex Frage on Tue, 05 Sep 2006 04:17:39 GMT]]></title><description><![CDATA[<p>hi,<br />
ich weiss nicht ob ich hier richtig bin...<br />
ich hab einen kleinen regex ausdruck definiert...<br />
warum funzt folgender ausdruck für den string test in der main nicht:</p>
<pre><code class="language-cpp">boost::regex rxSenderEmail
(
	&quot;(aRecip\&quot; title=\&quot;)&quot;  // intro
	&quot;( ([az]|[AZ]|[09]|\\@|\\.)* )&quot; // alles dazwischen + weitere
	&quot;(\&quot;)&quot;                 // outtro
);
</code></pre>
<p>was ist der unterschied zw. resMatch[ 0 ]; und resMatch[ 5 ]; bzw. *(resMatch[ 0 ].second) ...ist in der boost doku nicht verständlich;/</p>
<p>so gehts:</p>
<pre><code class="language-cpp">bool check_SenderEmail(const string strBuffer)
{
	boost::regex rxSenderEmail
	(
		&quot;aRecip\&quot; title=\&quot;&quot;       // intro
		&quot;(&quot;
		&quot;\\d|\\l|\\u|&quot;          // digits, lowers, uppers
		&quot;[\\?\\./=@%&amp;_-]&quot;       // extra chars in an email addy
		&quot;)*&quot;
		&quot;\&quot;&quot;                      // must end with inverted commas
	);

	typedef std::string::const_iterator str_cit;

	str_cit sciStart = strBuffer.begin();           // 1st offset of file or buffer
        str_cit sciEnd = strBuffer.end();             // last offset of file or buffer

        boost::match_results&lt; str_cit &gt; resMatch;
	boost::match_flag_type flgMatch = boost::match_default;

	string strMatch;

	if(regex_search(sciStart, sciEnd, resMatch, rxSenderEmail, flgMatch)) {
		strMatch = resMatch[ 0 ];
		strMatch.erase(0, 15);
		strMatch.erase(strMatch.length() - 1, 1);
		cout &lt;&lt; strMatch.c_str() &lt;&lt; endl;
		return true;
	}

	else return false;           // no match found
}

int main()
{
	string test(&quot;&lt;TD valign=\&quot;middle\&quot; align=\&quot;left\&quot;&gt;&lt;FONT color=\&quot;#000000\&quot; size=\&quot;2\&quot;&gt;&amp;nbsp;&lt;A href=\&quot;./?cmd=editrecipient&amp;Index=-1\&quot; class=\&quot;aRecip\&quot; title=\&quot;Max.Mustermann@klu.ac.at\&quot;&gt;&lt;FONT SIZE='2' COLOR=black&gt;Max Mustermann&lt;/FONT&gt;&lt;/A&gt;&lt;/FONT&gt;&lt;/TD&gt;&quot;);
	cout &lt;&lt; check_SenderEmail(test) &lt;&lt; endl;
        cin.get();
        return 0;
}
</code></pre>
<p>wie kann ich dem gematchen string bekommen ohne mit string::clear zu arbeiten? will also den string zwischen intro und outtro bekommen...</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1131220</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1131220</guid><dc:creator><![CDATA[cpp1]]></dc:creator><pubDate>Tue, 05 Sep 2006 04:17:39 GMT</pubDate></item><item><title><![CDATA[Reply to Boost::Regex Frage on Tue, 05 Sep 2006 07:08:26 GMT]]></title><description><![CDATA[<p>cpp1 schrieb:</p>
<blockquote>
<p>hi,<br />
ich weiss nicht ob ich hier richtig bin...<br />
ich hab einen kleinen regex ausdruck definiert...<br />
warum funzt folgender ausdruck für den string test in der main nicht:</p>
<pre><code class="language-cpp">boost::regex rxSenderEmail
(
	&quot;(aRecip\&quot; title=\&quot;)&quot;  // intro
	&quot;( ([az]|[AZ]|[09]|\\@|\\.)* )&quot; // alles dazwischen + weitere
	&quot;(\&quot;)&quot;                 // outtro
);
</code></pre>
</blockquote>
<p>Gegenfrage: Was funktioniert daran nicht? Compilerfehler? Laufzeitprobleme? Wörter nicht erkannt? ...?</p>
<blockquote>
<p>was ist der unterschied zw. resMatch[ 0 ]; und resMatch[ 5 ]; bzw. *(resMatch[ 0 ].second) ...ist in der boost doku nicht verständlich;/</p>
</blockquote>
<p>*schaut sich die Doku an*</p>
<p>match_results&lt;&gt;::operator[] liefert den i-ten Teiltreffer zurück (0 ist der Gesamtausdruck, alles andere sind die in Klammern eingeschlossenen Teilausdrücke - bei deinem obigen Beispiel dürfte also &quot;resMatch[1]&quot; den Intro-Anteil des erkannten Textes liefern. sub_match&lt;&gt; stammt von std::pair&lt;&gt; ab und packt in first/second den Anfang und das Ende der Sequenz und in matched eine Kennung, ob sie gültig ist.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1131251</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1131251</guid><dc:creator><![CDATA[CStoll]]></dc:creator><pubDate>Tue, 05 Sep 2006 07:08:26 GMT</pubDate></item><item><title><![CDATA[Reply to Boost::Regex Frage on Tue, 05 Sep 2006 10:58:32 GMT]]></title><description><![CDATA[<pre><code class="language-cpp">boost::regex rxSenderEmail
(
    &quot;(aRecip\&quot; title=\&quot;)&quot;  // intro
    &quot;( ([az]|[AZ]|[09]|\\@|\\.)* )&quot; // alles dazwischen + weitere
    &quot;(\&quot;)&quot;                 // outtro
);
</code></pre>
<p>dieser regex hier findet kein wort: &quot;aRecip\&quot; title=\&quot;Max.Mustermann@klu.ac.at\&quot;&quot; ich weiss aber auch nicht was daran falsch ist!?</p>
<p>mit dem funktionierenden regex:<br />
nur resMatch[ 0 ] liefert einen output...</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1131394</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1131394</guid><dc:creator><![CDATA[cpp1]]></dc:creator><pubDate>Tue, 05 Sep 2006 10:58:32 GMT</pubDate></item><item><title><![CDATA[Reply to Boost::Regex Frage on Tue, 05 Sep 2006 11:19:00 GMT]]></title><description><![CDATA[<p>Blind geraten - versuch's mal mit &quot;[a-z]&quot; etc. anstelle der [az] (oder jag testweise das Wort &quot;aRecip\&quot; title=\&quot;a1.z@aa.zz\&quot;&quot; durch deinen Ausdruck ;)).</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1131411</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1131411</guid><dc:creator><![CDATA[CStoll]]></dc:creator><pubDate>Tue, 05 Sep 2006 11:19:00 GMT</pubDate></item></channel></rss>