Boost logo

Boost Users :

Subject: [Boost-users] boost matching \b and match_not_null flag
From: Gavrilov, Roman (rgavrilov_at_[hidden])
Date: 2010-07-25 07:55:36


Hello,

I'm trying to find word boundaries with regex_search and "\b" pattern.

I have the following code:

 

string buff = "aaaa*******\\b";

boost::match_flag_type flags = boost::match_default |
boost::match_not_null;

boost::regex re("\\b");

boost::match_results<string::const_iterator> what;

 

string::const_iterator start = buff.begin();

string::const_iterator end = buff.end();

 

if ( regex_search(start, end, what, re, flags))

    {

        string out(start,what[0].second);

        cout << "match : " << out << endl;

    }

 

 

I would expect it to print "aaaa" in out string and to match the second
boundary, but in fact it didn't match anything.

If I remove the match_not_null flag then it will match the first
boundary at the beginning of the string as expected.

 

I don't understand this behavior, am I missing something?

Any help would be highly appreciated.

 

Thanks,

Roman



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