Boost logo

Boost Users :

Subject: [Boost-users] How to use Boost Regex Partial Match
From: Gundala Viswanath (gundalav_at_[hidden])
Date: 2009-04-15 06:14:34


Dear all,

Given this code. I expect to get this output from the corresponding input:

Input: FOO Output: Match
Input: FOOBAR, Output: Match
Input: BAR, Output: No Match

But why it gives "No Match" for input FOOBAR?

__BEGIN__
#include <iostream>
#include <vector>
#include <fstream>
#include <sstream>
#include <boost/regex.hpp>
using namespace std;
using namespace boost;

int main ( int arg_count, char *arg_vec[] ) {
    if (arg_count !=2 ) {
        cerr << "expected one argument" << endl;
        return EXIT_FAILURE;
    }

    string InputString = arg_vec[1];
    string toMatch = "FOO";

    const regex e(toMatch);
    if (regex_match(InputString, e,match_partial)) {
        cout << "Match" << endl;
    } else {
        cout << "No Match" << endl;
    }

    return 0;
}


Boost-users list run by williamkempf at hotmail.com, kalb at libertysoft.com, bjorn.karlsson at readsoft.com, gregod at cs.rpi.edu, wekempf at cox.net