boost matching \b and match_not_null flag
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_resultsstring::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
Ohhhh, you're right. Thanks. -----Original Message----- From: boost-users-bounces@lists.boost.org [mailto:boost-users-bounces@lists.boost.org] On Behalf Of John Maddock Sent: Sunday, July 25, 2010 19:48 To: boost-users@lists.boost.org Subject: Re: [Boost-users] boost matching \b and match_not_null flag
I don't understand this behavior, am I missing something?
You have set a flag that says "never match a zero length string" and passed a regular expression that can *only ever match a zero length string* ... as a result no match can ever be found. HTH, John. _______________________________________________ Boost-users mailing list Boost-users@lists.boost.org http://lists.boost.org/mailman/listinfo.cgi/boost-users
participants (2)
-
Gavrilov, Roman
-
John Maddock