Boost logo

Boost Users :

Subject: Re: [Boost-users] Xpressive continuing search from previous match
From: Belcourt, Kenneth (kbelco_at_[hidden])
Date: 2010-01-07 23:14:44


On Jan 7, 2010, at 8:14 PM, Eric Niebler wrote:

> On 1/8/2010 11:21 AM, K. Noel Belcourt wrote:
>>
>> On Jan 7, 2010, at 5:01 PM, K. Noel Belcourt wrote:
>>
>>> I have a search for a regular expression like this.
>>>
>>> sregex_iterator cur(buffer.begin(), buffer.end(), defined_re), end;
>>> for(; cur != end; ++cur) { ...
>>>
>>> But what I really want to do is perform a new regex search starting
>>> at the location in the buffer marking the end of the previous
>>> search.
>
> That's exactly what sregex_iterator does.
>
>>> Is there a way to get the buffer index from the previous
>>> search so I can start the new search past the previous search?
>>
>> Okay, seems like you can use:
>>
>> smatch const &what = *cur;
>> what.position();
>>
>> to give you the byte offset into the buffer.
>
> That would give you the offset (aka, distance; NOT the byte offset) of
> where the last match *begins*, not where it ends.

Yup, when I'm in a hurry to get something done, as I was this
afternoon, I tend to play fast and loose with the semantics.

> Confuzzled,

Converged, to the solution I needed. I'm amazed at how quickly I
solved my problem (< 4 hours) given that I'd never even looked at the
xpressive library or it's documentation.

Thanks for a great library Eric!

-- Noel


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