none
#include <regex> in VS2012 RRS feed

  • Frage

  • Hallo,

    in VS2008 ging das noch mit

    #include <regex>

    in VS2012 wird es nicht gefunden.

    Muss ich das anders schreiben?

    Wer weiß Rat?

    Grüße Sandra

      1 #include <iostream>
      2 #include <fstream>
      3 #include <regex>
      4 
      5 using namespace tr1;
      6 using namespace std;
      7 
      8 int main()
      9 {
     10 std::string str = "Hello world";
     11 std::tr1::regex rx("ello");
     12 
     13 if(regex_match(str.begin(), str.end(), rx))
     14 {
     15 cout<<"false"<<endl;
     16 }
     17 else
     18 cout<<"true"<<endl;
     19 return(0);
     20 }

    Mittwoch, 27. Mai 2015 13:11

Alle Antworten

  • Hallo Sandra,

    das include ist so korrekt.

    Da regex Teil des verwendeten Standards im VS2012 Compiler ist, fällt die tr1 Erweiterung raus. Du schreibst leider nicht, was nicht gefunden wird, ich nehme daher einfach mal an, das es tr1 ist. Daher würde ich es mal so probieren:

      1 #include <iostream>
      2 
      3 #include <regex>
      4 
      5 
      6 using namespace std;
      7 
      8 int main()
      9 {
     10 string str = "Hello world";
     11 regex rx("ello");
     12 
     13 if(regex_match(str.begin(), str.end(), rx))
     14 {
     15 cout<<"false"<<endl;
     16 }
     17 else
     18 cout<<"true"<<endl;
     19 return(0);
     20 }

    using namespace oder nicht, kläre das mal für Dich - einmal mit und einmal ohne ist verwirrend.

    Gruß


    - Florian


    • Bearbeitet Florian Haupt Mittwoch, 27. Mai 2015 13:32 nicht relevantes include entfernt
    Mittwoch, 27. Mai 2015 13:26

  •   1 #include <iostream>
      2 #include <fstream>
      3 #include <regex>
      4 
      5 

      3 #include <regex>

    Hallo,

    der Compiler gibt Fehler an dieser Stelle aus. Muss ich am Freitag oder Montag genauer testen.

    Grüße Sandra

    Mittwoch, 27. Mai 2015 13:31
  • Kann ich so nicht reproduzieren. Hab es soeben unter VS2012 kompiliert und laufen lassen.

    - Florian

    Mittwoch, 27. Mai 2015 13:41
  • Kann ich so nicht reproduzieren. Hab es soeben unter VS2012 kompiliert und laufen lassen.


    OK, muss ich dann nochmals genauer anschauen, ggf. melde ich nochmals.

    Grüße Sandra

    Mittwoch, 27. Mai 2015 14:35
  • Besteht das Problem noch?

    - Florian

    Donnerstag, 18. Juni 2015 13:17