class template


template <class BidirectionalIterator,
          class charT=typename iterator_traits<BidirectionalIterator>::value_type,
          class traits=regex_traits<charT> > class regex_iterator;
Regex iterator
Iterator type to iterate over different matches of a same regex pattern in a sequence.

When constructed, and every time operator++ is applied to it, the iterator performs a regex_search to find successive matches on a sequence. Dereferencing a valid regex_iterator yields a match_results object.

A special value of regex_iterator is used to indicate an end-of-sequence. This iterator should not be dereferenced. Its value is the same for all end-of-sequence regex_iterator objects of the same type, no matter the sequence being iterated by each.

Internally, the object keeps a match_results object with the information about the most recent match (if any), which is updated every time the iterator is incremented with operator++. A reference to this object is returned when the iterator is dereferenced using operator*.

Apart from that match_results object, the iterator keeps internally the following information set either on construction or due to an assignment operation:
  • the beginning and the end of the entire target sequence
  • a set of flags
  • a reference to the regex object to be used (notice that only a reference to it is kept and not a copy).

Template parameters

A bidirectional iterator type that iterates on the target sequence of characters.
The character type.
A regex traits type (see regex_traits for further info).

Member types

The following aliases are member types of match_results. They are widely used as parameter and return types by member functions:

member typedefinitionnotes
regex_typebasic_regex<charT,traits>Type of the basic_regex object used as pattern.
value_typematch_results<BidirectionalIterator>Type of the elements iterated (match_results).
pointerconst value_type*
referenceconst value_type&
difference_typestd::ptrdiff_tA signed integral type (see ptrdiff_t).
iterator_categorystd::forward_iterator_tagForward iterator

Member functions