using boost.regex on submatches.
Hi,
I have a problem using boost.regex to parse a message.
The message contains an unknown number of handles terminated by a tab.
Each handle has four hex digits. To find the block of handles I use
a regex search and then I want to use an iterator to split up the block.
#include <iostream>
#include
AMDG Dan Smithers wrote:
boost::sregex_iterator it(sm[1].str().begin(), sm[1].str().end(), handles);
str() returns a std::string by *value* Thus, the two iterators point into different string objects.
I get a segmentation fault if I run this - sometimes with a memory exhausted notice.
If I replace the iterator line
boost::sregex_iterator it(sm[1].str().begin(), sm[1].str().end(), handles);
with
const string& hs(sm[1].str()); boost::sregex_iterator it(hs.begin(), hs.end(), handles);
then everything seems to work.
What's going on here? Is there a simpler way of achieving this?
Now you only get one string object. In Christ, Steven Watanabe
participants (2)
-
Dan Smithers
-
Steven Watanabe