Boost logo

Boost Users :

From: Lynn Allan (l_d_allan_at_[hidden])
Date: 2006-04-12 16:23:10


Eric Niebler wrote:
> Lynn Allan wrote:
>>
>> The subsequent searches give valid information about the length and
>> position, but other fields in the smatch:what variable seem
>> invalid.
>> regex_search( altDow.substr(32), what, rex)
>> regex_search( altDow.substr(45), what, rex)
>
> Watch out! altDow.substr(32) is returning a temporary string object.
> After regex_search returns, the temporary is destroyed and the
> results
> object is left holding iterators into a destroyed string.

Arggggg. Trying to get "up to speed" with Boost is probably a flawed
thing to try to do at the same time as learning rudimentary aspects of
STL. "We're not in MFC-land any more, Toto." <g>

std::string altDow32 = altDow.substr(32);
if( regex_search( altDow32, what, rex ) ) { unpack }

The above (ugly) code clears up the "self inflicted wound". I'm
"holding my nose" and using it to "unpack" the contents of the
match_results variables. Thanks for the clarification.

>> Regardless, I'm unclear how to tell which of the "groups" of
>> subexpressions was "hit". With boost::regex there was a way to loop
>> thru the boolean field:
>> what[i].matched
>> and see what "hit", but I am not seeing a comparable accessor.
>
> Xpressive is no different that Boost.Regex in this regard.
> what[i].matched is correct.

Works well. I think an earlier "trial and error stab at it" used
what[i].matched() and back-tracked too far when the compiler
complained. Your documentation is superior, but I've got a long ways
to go to understand template notation adequately.

Thanks again for your patience ....


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