boost.regex not working?

This is a discussion on boost.regex not working? within the C++ Programming forums, part of the General Programming Boards category; I've read the manual. I've checked the example. But I don't get it. Code: boost::regex expres("([0-9]+)"); boost::cmatch matches; boost::regex_match(buff.c_str(), matches, ...

  1. #1
    Registered User
    Join Date
    Aug 2007
    Posts
    85

    boost.regex not working?

    I've read the manual. I've checked the example. But I don't get it.

    Code:
        boost::regex expres("([0-9]+)");
        boost::cmatch matches;
        boost::regex_match(buff.c_str(), matches, expres);
    
        for (unsigned int i = 1; i < matches.size(); i++)
         {
            std::string match(matches[i].first, matches[i].second);
            cout << (match + ";") << endl;
         }
    Code above is not working. I get nothing on cout.

    buff is a string retrieved by curl from www.google.com. It contains the code. And there are numbers in it.

  2. #2
    Registered User
    Join Date
    Aug 2007
    Posts
    85
    Hmm, never found this in examples.
    It seems like .+([0-9]+?).+ does the trick.
    I thought this would work the normal way, as in php's preg, if you pass it some expression, it will look for a match of that expression somewhere in the string, not an exact match of the expression to the string

  3. #3
    Captain Crash brewbuck's Avatar
    Join Date
    Mar 2007
    Location
    Portland, OR
    Posts
    7,158
    Quote Originally Posted by _izua_ View Post
    Code above is not working. I get nothing on cout.
    Use regex_search(), not regex_match().

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Function not working
    By sloopy in forum C Programming
    Replies: 31
    Last Post: 11-12-2005, 07:08 PM
  2. Program Not working Right
    By raven420smoke in forum C++ Programming
    Replies: 2
    Last Post: 09-16-2005, 03:21 AM
  3. Trying to eject D drive using code, but not working... :(
    By snowfrog in forum C++ Programming
    Replies: 3
    Last Post: 05-07-2005, 07:47 PM
  4. x on upper right corner not working
    By caduardo21 in forum Windows Programming
    Replies: 1
    Last Post: 02-20-2005, 07:35 PM
  5. cygwin -> unix , my code not working properly ;(
    By CyC|OpS in forum C Programming
    Replies: 4
    Last Post: 05-18-2002, 04:08 AM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21