Thread: boost.regex not working?

  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
    Officially An Architect brewbuck's Avatar
    Join Date
    Mar 2007
    Location
    Portland, OR
    Posts
    7,396
    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, 08: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, 08: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