[re.regiter.general]

# 28 Text processing library [[text]](./#text)

## 28.6 Regular expressions library [[re]](re#regiter.general)

### 28.6.11 Regular expression iterators [[re.iter]](re.iter#re.regiter.general)

#### 28.6.11.1 Class template regex_iterator [[re.regiter]](re.regiter#general)

#### 28.6.11.1.1 General [re.regiter.general]

[1](#1)

[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/text.tex#L12225)

The class template regex_iterator is an iterator adaptor[.](#1.sentence-1)

It represents a new view of an existing iterator sequence, by
enumerating all the occurrences of a regular expression within that
sequence[.](#1.sentence-2)

A regex_iterator uses regex_search to find successive
regular expression matches within the sequence from which it was
constructed[.](#1.sentence-3)

After the iterator is constructed, and every time operator++ is
used, the iterator finds and stores a value ofmatch_results<BidirectionalIterator>[.](#1.sentence-4)

If the end of the sequence is
reached (regex_search returns false), the iterator becomes equal to
the end-of-sequence iterator value[.](#1.sentence-5)

The default constructor
constructs an end-of-sequence iterator object,
which is the only legitimate iterator to be used for the end
condition[.](#1.sentence-6)

The result of operator* on an end-of-sequence iterator is not
defined[.](#1.sentence-7)

For any other iterator value aconst match_results<BidirectionalIterator>& is returned[.](#1.sentence-8)

The result ofoperator-> on an end-of-sequence iterator is not defined[.](#1.sentence-9)

For any other
iterator value a const match_results<BidirectionalIterator>* is
returned[.](#1.sentence-10)

It is impossible to store things into regex_iterators[.](#1.sentence-11)

Two
end-of-sequence iterators are always equal[.](#1.sentence-12)

An end-of-sequence
iterator is not equal to a non-end-of-sequence iterator[.](#1.sentence-13)

Two
non-end-of-sequence iterators are equal when they are constructed from
the same arguments[.](#1.sentence-14)

namespace std {template<class BidirectionalIterator, class charT = typename iterator_traits<BidirectionalIterator>::value_type, class traits = regex_traits<charT>>class regex_iterator {public:using regex_type = basic_regex<charT, traits>; using iterator_category = forward_iterator_tag; using iterator_concept = input_iterator_tag; using value_type = match_results<BidirectionalIterator>; using difference_type = ptrdiff_t; using pointer = const value_type*; using reference = const value_type&;

 regex_iterator();
 regex_iterator(BidirectionalIterator a, BidirectionalIterator b, const regex_type& re,
 regex_constants::match_flag_type m = regex_constants::match_default);
 regex_iterator(BidirectionalIterator, BidirectionalIterator, const regex_type&&,
 regex_constants::match_flag_type = regex_constants::match_default) = delete;
 regex_iterator(const regex_iterator&);
 regex_iterator& operator=(const regex_iterator&); bool operator==(const regex_iterator&) const; bool operator==(default_sentinel_t) const { return *this == regex_iterator(); }const value_type& operator*() const; const value_type* operator->() const;
 regex_iterator& operator++();
 regex_iterator operator++(int); private: BidirectionalIterator begin; // *exposition only* BidirectionalIterator end; // *exposition only*const regex_type* pregex; // *exposition only* regex_constants::match_flag_type flags; // *exposition only* match_results<BidirectionalIterator> match; // *exposition only*};}

[2](#2)

[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/text.tex#L12292)

An object of type regex_iterator that is not an end-of-sequence iterator
holds a *zero-length match* if match[0].matched == true andmatch[0].first == match[0].second[.](#2.sentence-1)

[*Note [1](#note-1)*:

For
example, this can occur when the part of the regular expression that
matched consists only of an assertion (such as `'^'`, `'$'`,'\b', '\B')[.](#2.sentence-2)

â *end note*]
