<?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[c++11 regex - unverstaendnis]]></title><description><![CDATA[<p>Hallo zusammen</p>
<p>ich beschäftige mich gerade mit regex, da diese mir doch abundan weiterhelfen könnten. Beim Ausprobieren bin ich auf ein Problem oder besser gesagt auf Unverständnis ( bei mir ) gestoßen.</p>
<p>sourcecode:</p>
<pre><code>{
      std::string s(&quot;01010101&quot;);
      std::string pattern(&quot;0*.*&quot;);
      std::regex e(pattern, std::regex::icase);
      if (std::regex_match(s, e, std::regex_constants::match_default))
         std::cout &lt;&lt; &quot;matching: &quot;;
      else
         std::cout &lt;&lt; &quot;NO matching: &quot;;

      std::cout &lt;&lt; &quot;\&quot;&quot; &lt;&lt; s &lt;&lt; &quot;\&quot; (pattern: &quot; &lt;&lt; pattern &lt;&lt; &quot;)\n&quot;;
   }

   {
      std::string s(&quot;01010101&quot;);
      std::string pattern(&quot;[0-1]*.*&quot;);
      std::regex e(pattern, std::regex::icase);
      if (std::regex_match(s, e, std::regex_constants::match_default))
         std::cout &lt;&lt; &quot;matching: &quot;;
      else
         std::cout &lt;&lt; &quot;NO matching: &quot;;

      std::cout &lt;&lt; &quot;\&quot;&quot; &lt;&lt; s &lt;&lt; &quot;\&quot; (pattern: &quot; &lt;&lt; pattern &lt;&lt; &quot;)\n&quot;;
   }
</code></pre>
<p>Output:<br />
matching: &quot;01010101&quot; (pattern: 0*.<em>)<br />
NO matching: &quot;01010101&quot; (pattern: [0-1]</em>.*)</p>
<p>1.)<br />
Das erste ergibt für mich Sinn.<br />
Das zweite jedoch nicht. Ich sage doch, dass Ziffern von 0-1 erlaubt sind.</p>
<p>Wieso matched das zweite nicht?</p>
<p>2.)<br />
Sobald ich diese &quot;[]&quot; verwende, und auf &quot;std::regex::icase&quot; verzichte, bekomme ich eine Exception. Warum?</p>
<p>Mir scheint, dass mir hier noch einiges an Verständnis für reguläre Ausdrücke fehlt... Vielleicht könnt ihr mir weiterhelfen <img
      src="https://www.c-plusplus.net/forum/plugins/nodebb-plugin-emoji/emoji/emoji-one/1f609.png?v=ab1pehoraso"
      class="not-responsive emoji emoji-emoji-one emoji--winking_face"
      title=";)"
      alt="😉"
    /></p>
]]></description><link>https://www.c-plusplus.net/forum/topic/325903/c-11-regex-unverstaendnis</link><generator>RSS for Node</generator><lastBuildDate>Sat, 11 Jul 2026 16:18:44 GMT</lastBuildDate><atom:link href="https://www.c-plusplus.net/forum/topic/325903.rss" rel="self" type="application/rss+xml"/><pubDate>Fri, 23 May 2014 06:50:25 GMT</pubDate><ttl>60</ttl><item><title><![CDATA[Reply to c++11 regex - unverstaendnis on Fri, 23 May 2014 06:50:55 GMT]]></title><description><![CDATA[<p>Hallo zusammen</p>
<p>ich beschäftige mich gerade mit regex, da diese mir doch abundan weiterhelfen könnten. Beim Ausprobieren bin ich auf ein Problem oder besser gesagt auf Unverständnis ( bei mir ) gestoßen.</p>
<p>sourcecode:</p>
<pre><code>{
      std::string s(&quot;01010101&quot;);
      std::string pattern(&quot;0*.*&quot;);
      std::regex e(pattern, std::regex::icase);
      if (std::regex_match(s, e, std::regex_constants::match_default))
         std::cout &lt;&lt; &quot;matching: &quot;;
      else
         std::cout &lt;&lt; &quot;NO matching: &quot;;

      std::cout &lt;&lt; &quot;\&quot;&quot; &lt;&lt; s &lt;&lt; &quot;\&quot; (pattern: &quot; &lt;&lt; pattern &lt;&lt; &quot;)\n&quot;;
   }

   {
      std::string s(&quot;01010101&quot;);
      std::string pattern(&quot;[0-1]*.*&quot;);
      std::regex e(pattern, std::regex::icase);
      if (std::regex_match(s, e, std::regex_constants::match_default))
         std::cout &lt;&lt; &quot;matching: &quot;;
      else
         std::cout &lt;&lt; &quot;NO matching: &quot;;

      std::cout &lt;&lt; &quot;\&quot;&quot; &lt;&lt; s &lt;&lt; &quot;\&quot; (pattern: &quot; &lt;&lt; pattern &lt;&lt; &quot;)\n&quot;;
   }
</code></pre>
<p>Output:<br />
matching: &quot;01010101&quot; (pattern: 0*.<em>)<br />
NO matching: &quot;01010101&quot; (pattern: [0-1]</em>.*)</p>
<p>1.)<br />
Das erste ergibt für mich Sinn.<br />
Das zweite jedoch nicht. Ich sage doch, dass Ziffern von 0-1 erlaubt sind.</p>
<p>Wieso matched das zweite nicht?</p>
<p>2.)<br />
Sobald ich diese &quot;[]&quot; verwende, und auf &quot;std::regex::icase&quot; verzichte, bekomme ich eine Exception. Warum?</p>
<p>Mir scheint, dass mir hier noch einiges an Verständnis für reguläre Ausdrücke fehlt... Vielleicht könnt ihr mir weiterhelfen <img
      src="https://www.c-plusplus.net/forum/plugins/nodebb-plugin-emoji/emoji/emoji-one/1f609.png?v=ab1pehoraso"
      class="not-responsive emoji emoji-emoji-one emoji--winking_face"
      title=";)"
      alt="😉"
    /></p>
]]></description><link>https://www.c-plusplus.net/forum/post/2400458</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2400458</guid><dc:creator><![CDATA[It0101]]></dc:creator><pubDate>Fri, 23 May 2014 06:50:55 GMT</pubDate></item><item><title><![CDATA[Reply to c++11 regex - unverstaendnis on Fri, 23 May 2014 07:30:11 GMT]]></title><description><![CDATA[<p>Ich sehe keinen Fehler. Du könntest [01] schreiben.</p>
<p>Welchen Compiler verwendest du? gcc 4.8 kann z.B. noch nicht alles. Im Zweifelsfall geht boost.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/2400466</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2400466</guid><dc:creator><![CDATA[manni66]]></dc:creator><pubDate>Fri, 23 May 2014 07:30:11 GMT</pubDate></item><item><title><![CDATA[Reply to c++11 regex - unverstaendnis on Fri, 23 May 2014 07:36:57 GMT]]></title><description><![CDATA[<p>Welches Script wird denn genommen, wenn man nur icase setzt?<br />
Setz mal im Ctor auch ECMAScript | icase</p>
]]></description><link>https://www.c-plusplus.net/forum/post/2400468</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2400468</guid><dc:creator><![CDATA[Jockelx]]></dc:creator><pubDate>Fri, 23 May 2014 07:36:57 GMT</pubDate></item><item><title><![CDATA[Reply to c++11 regex - unverstaendnis on Fri, 23 May 2014 08:43:38 GMT]]></title><description><![CDATA[<p>manni66 schrieb:</p>
<blockquote>
<p>Ich sehe keinen Fehler. Du könntest [01] schreiben.</p>
<p>Welchen Compiler verwendest du? gcc 4.8 kann z.B. noch nicht alles. Im Zweifelsfall geht boost.</p>
</blockquote>
<p>manni hat recht. mit dem G++ 4.9 ergibt sich einwandfrei</p>
<p>matching: &quot;01010101&quot; (pattern: 0*.*)</p>
<p>matching: &quot;01010101&quot; (pattern: [0-1]<em>.</em>)</p>
]]></description><link>https://www.c-plusplus.net/forum/post/2400477</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2400477</guid><dc:creator><![CDATA[regextest]]></dc:creator><pubDate>Fri, 23 May 2014 08:43:38 GMT</pubDate></item><item><title><![CDATA[Reply to c++11 regex - unverstaendnis on Fri, 23 May 2014 08:44:56 GMT]]></title><description><![CDATA[<p>ok, dann liegts wohl am compiler...</p>
]]></description><link>https://www.c-plusplus.net/forum/post/2400478</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2400478</guid><dc:creator><![CDATA[It0101]]></dc:creator><pubDate>Fri, 23 May 2014 08:44:56 GMT</pubDate></item><item><title><![CDATA[Reply to c++11 regex - unverstaendnis on Fri, 23 May 2014 11:23:20 GMT]]></title><description><![CDATA[<p>In diese Falle bin ich auch getappt. Dass keine Exception geworfen wird oder gar das Kompilieren verhindert wird, finde ich ziemlich unbefrieigend.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/2400495</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2400495</guid><dc:creator><![CDATA[theta]]></dc:creator><pubDate>Fri, 23 May 2014 11:23:20 GMT</pubDate></item><item><title><![CDATA[Reply to c++11 regex - unverstaendnis on Fri, 23 May 2014 12:16:28 GMT]]></title><description><![CDATA[<p>regextest schrieb:</p>
<blockquote>
<p>manni66 schrieb:</p>
<blockquote>
<p>Ich sehe keinen Fehler. Du könntest [01] schreiben.</p>
<p>Welchen Compiler verwendest du? gcc 4.8 kann z.B. noch nicht alles. Im Zweifelsfall geht boost.</p>
</blockquote>
<p>manni hat recht. mit dem G++ 4.9 ergibt sich einwandfrei</p>
<p>matching: &quot;01010101&quot; (pattern: 0*.*)</p>
<p>matching: &quot;01010101&quot; (pattern: [0-1]<em>.</em>)</p>
</blockquote>
<p>Nur mal so am Rande: &quot;0*.*&quot; ist das gleiche wie &quot;&quot;, matcht (matched?, matscht <img
      src="https://www.c-plusplus.net/forum/plugins/nodebb-plugin-emoji/emoji/emoji-one/1f603.png?v=ab1pehoraso"
      class="not-responsive emoji emoji-emoji-one emoji--grinning_face_with_big_eyes"
      title=":D"
      alt="😃"
    /> ) also alles. Das 2. Pattern genauso.</p>
<p>&quot;<em>&quot; bedeutet 0 oder mehrmals. Damit matcht 0</em> auch, wenn keine 0 vor kommt. &quot;.<em>&quot; bedeutet ein beliebiges Zeichen 0 oder mehrmals. Also irgendetwas kein mal findet sich immer irgendwo. &quot;[0-1]</em>&quot; sucht nach 0 oder 1, ist aber auch zufrieden, wenn es 0 mal vorkommt.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/2400504</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2400504</guid><dc:creator><![CDATA[tntnet]]></dc:creator><pubDate>Fri, 23 May 2014 12:16:28 GMT</pubDate></item></channel></rss>