Boost logo

Boost :

From: Dave Gomboc (dave_at_[hidden])
Date: 2003-06-28 14:49:24


Thanks for the quick fixes on the other bug reports, John.

Here is what might be a new one. The code below indicates that no match
was found, but I was expecting it to indicate that a partial match was
found beginning at 'a'. If I don't push the space on beforehand, I do
get a partial match. Have I overlooked something?

#include <boost/regex.hpp>

#include <iostream>
#include <vector>

int main(void) {

    typedef char value_type;
    typedef std::vector<value_type> container_type;
    typedef container_type::iterator iterator_type;

    boost::regex find_this("ab");
    container_type search_this;
    search_this.push_back(' ');
    search_this.push_back('a');

    boost::match_results< iterator_type > what_matched;
    bool match_found(boost::regex_search(search_this.begin(),
     search_this.end(), what_matched, find_this,
     boost::match_default | boost::match_partial));

    if (match_found) {
        if (what_matched[0].matched) {
            std::cout << "Full match found." << std::endl;
        } else {
            std::cout << "Partial match found." << std::endl;
        };
    } else {
        std::cout << "No match found." << std::endl;
    };

};


Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk