http://gcc.gnu.org/bugzilla/show_bug.cgi?id=58886

            Bug ID: 58886
           Summary: regex with (?s) (valid in Java and boost) yields
                    regex_error
           Product: gcc
           Version: 4.9.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: libgcc
          Assignee: unassigned at gcc dot gnu.org
          Reporter: bremende55 at gmail dot com

regex  with (?s) (valid in Java and boost) yields regex_error
(?s) ist the 'dot-matches-all" match mode, i.e. \n ist treated as normal char
see example:

#include <iostream>
#include <regex>
#include <string>
int main() {
   std::string multilinecomment("/* text\n\n\n */");
// execution of the next line gives regex_error !!
   std::string result = std::regex_replace(multilinecomment, 
                           std::regex("(?s)/\\*.*?\\*/"), "replacement");
   std::cout << result << std::endl;  
}
// The same code DOES WORK with BOOST:
// #include <iostream>
// #include<boost/regex.hpp>
// #include <string>
// int main() {
//    std::string multilinecomment("/* text\n\n\n */");
//    std::string result = boost::regex_replace(multilinecomment, 
//                            boost::regex("(?s)/\\*.*?\\*/"), "replacement");
//    std::cout << result << std::endl;  // replacement
// }

Reply via email to