help with this problem please

Discussion in 'C++' started by nvangogh, Nov 11, 2012.

  1. nvangogh

    nvangogh Guest

    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.
    nvangogh, Nov 11, 2012
    #1
    1. Advertising

  2. nvangogh

    Melzzzzz Guest

    On Sun, 11 Nov 2012 19:08:53 GMT
    nvangogh <> 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.
    Melzzzzz, Nov 11, 2012
    #2
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Replies:
    4
    Views:
    506
    Chris Uppal
    May 5, 2005
  2. KK
    Replies:
    2
    Views:
    550
    Big Brian
    Oct 14, 2003
  3. MuZZy
    Replies:
    7
    Views:
    1,745
    Mike Hewson
    Jan 7, 2005
  4. Replies:
    1
    Views:
    325
    Roedy Green
    Apr 23, 2008
  5. mera
    Replies:
    7
    Views:
    1,100
Loading...

Share This Page