Velocity Reviews

Velocity Reviews (http://www.velocityreviews.com/forums/index.php)
-   C++ (http://www.velocityreviews.com/forums/f39-c.html)
-   -   help with this problem please (http://www.velocityreviews.com/forums/t954417-help-with-this-problem-please.html)

nvangogh 11-11-2012 07:08 PM

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.



Melzzzzz 11-11-2012 07:19 PM

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.


1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57