![]() |
help with this problem please
Icompiled this program after reading the code from C++ Primer 5th Edition
page 729. I used the C++11 standard flag on the gcc 4.7 compiler. The program compiles without any problems: code: #include <iostream> #include <regex> #include <string> int main() { std::string pattern("[^c]ei"); pattern = "[[:alpha:]]*" + pattern + "[[:alpha:]]*"; std::regex r(pattern); std::smatch results; std::string test_str = "receipt freind theif receive"; if(std::regex_search(test_str, results, r)) std::cout << results.str() << std::endl; return 0; } ----------- When I run the program I get: terminate called after throwing an instance of 'std::regex_error' what(): regex_error Abort trap (core dumped) ---------------- I have tried this program with exception handling to try and find out more about the error, but all I got was error signal 4. I know that the regex class uses ECMAscript as default and that this is tested at runtime. Unfortunately, I cannot see what the problem is. |
Re: help with this problem please
On Sun, 11 Nov 2012 19:08:53 GMT
nvangogh <nvangogh@invalid.net> wrote: > Icompiled this program after reading the code from C++ Primer 5th > Edition page 729. I used the C++11 standard flag on the gcc 4.7 > compiler. The program compiles without any problems: > > code: > > #include <iostream> > #include <regex> > #include <string> > > int main() > { > std::string pattern("[^c]ei"); > pattern = "[[:alpha:]]*" + pattern + "[[:alpha:]]*"; > > std::regex r(pattern); > std::smatch results; > > std::string test_str = "receipt freind theif receive"; > > if(std::regex_search(test_str, results, r)) > std::cout << results.str() << std::endl; > > return 0; > } > > ----------- > When I run the program I get: > terminate called after throwing an instance of 'std::regex_error' > what(): regex_error > Abort trap (core dumped) > ---------------- > > I have tried this program with exception handling to try and find out > more about the error, but all I got was error signal 4. I know that > the regex class uses ECMAscript as default and that this is tested at > runtime. Unfortunately, I cannot see what the problem is. > Problem is that regex implementation in gcc's libstdc++ is not complete, therefore exception. |
| All times are GMT. The time now is 03:15 PM. |
Powered by vBulletin®. Copyright ©2000 - 2013, vBulletin Solutions, Inc.
SEO by vBSEO ©2010, Crawlability, Inc.