Boost logo

Boost Users :

Subject: [Boost-users] [boost-regex] 1.47.0 regexp_search with match_partial does not return 'what'
From: Frank Bergemann (fbergemann_at_[hidden])
Date: 2013-09-18 02:15:47


I can't get proper information in 'what' for a regex_search with match_partial.
Here's  a little demo program:
================================
#include <cstring>
#include <iostream>
#include <boost/regex.hpp>
int main(int, char**)
{
    boost::regex regex("<(/)?my:meta[^>]*>", boost::regex::extended);
    char test[] = "<demo test/><my:meta";
    boost::match_flag_type flags(boost::match_default | boost::match_partial);
    boost::match_results<char*> what;
    bool check = boost::regex_search(test, test + strlen(test), what, regex, flags);
    std::cout << "test = " << test << ", test-start = " << (long) test << ", test-end = " << (long)test + strlen(test) << std::endl;
    std::cout << "check = " << (check ? "match" : "mismatch") << std::endl;
    if (check)
    {
        std::cout << "what[0].matched = " << (what[0].matched ? "full" : "partial") << " match" << std::endl;
        std::cout << "what[0].first = " << (long) what[0].first << ", what[0].second = " << (long)what[0].second << std::endl;
    }
    return 0;
}
================================
The output:
================================
test = <demo test/><my:meta, test-start = 140733633399792, test-end = 140733633399812
check = match
what[0].matched = partial match
what[0].first = 140733633399812, what[0].second = 140733633399812
================================
Though there is a partial match, both what[0].first and what[0].second return the test-end value (end of buffer (excl.)).
But i need the correct positions for a buffer handling.
 
regards,
Frank

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