Here, with
sregex_iterator pos(data.cbegin(),data.cend(),reg);
we initialize a regex iterator, iterating over data to search for matches of reg. The default constructor of this type defines a past-the-end iterator:
sregex_iterator end;
We can now use this iterator as any other bidirectional iterator (see Section 9.2.4, page 437): Opera- tor * yields the current match, while operators ++ and -- move to the next or previous match. Thus, the following prints all the matches, their tags, and their values (as in the previous example):