Problems with Open-Source Downloads read https://www.qt.io/blog/problem-with-open-source-downloads and https://forum.qt.io/post/638946

How to use std::regex in QtCreator?



  • Greetings,

    the following C++ code line causes a crash (segfault) when debugging in QtCreator:

    std::regex rg("^\\s*someText\\s*");
    

    The following variant crashes as well:

    std::basic_string<char> s("^\\s*someText\\s*");
    std::regex rg(s);
    

    Is there some special handling which is needed for std::regex?

    (P.S. I know about Qt regex classes. Can std::regex be used in Qt?)

    Thanks.



  • Hi, and welcome to the Qt forum! That's not a problem specific to Qt but to your compiler. I guess you run GCC 4.8.x. You'll need at least 4.9.x for regex to work as expected. See also: http://en.cppreference.com/w/cpp/regex



  • Thank you very much for quick response and solving the problem.


Log in to reply