regex_token_iterator Class

Iterator class for submatches.

template<class BidIt, class Elem = iterator_traits<BidIt>::value_type,
    class RXtraits = regex_traits<Elem> >
        class regex_token_iterator {
    typedef basic_regex<Elem, RXtraits> regex_type;
    typedef sub_match<BidIt> value_type;
    typedef std::forward_iterator_tag iterator_category;
    typedef std::ptrdiff_t difference_type;
    typedef const sub_match<BidIt> *pointer;
    typedef const sub_match<BidIt>& reference;

    regex_token_iterator(BidIt first, BidIt last,
        const regex_type& re, int submatch = 0,
        regex_constants::match_flag_type f = regex_constants::match_default);
    regex_token_iterator(BidIt first, BidIt last,
        const regex_type& re, const std::vector<int> submatches,
        regex_constants::match_flag_type f = regex_constants::match_default);
    template<std::size_t N>
    regex_token_iterator(BidIt first, BidIt last,
        const regex_type& re, const int (&submatches)[N],
        regex_constants::match_flag_type f = regex_constants::match_default);

    bool operator==(const regex_token_iterator& right);
    bool operator!=(const regex_token_iterator& right);
    const basic_string<Elem>& operator*();
    const basic_string<Elem> *operator->();
    regex_token_iterator& operator++();
    regex_token_iterator& operator++(int);
    regex_iterator<BidIt, Elem, RXtraits> it; // exposition only
    vector<int> subs;                         // exposition only
    int pos;                                  // exposition only


The iterator type for submatches.


The type of elements to match.


Traits class for elements.

The template class describes a constant forward iterator object. Conceptually, it holds a regex_iterator object that it uses to search for regular expression matches in a character sequence. It extracts objects of type sub_match<BidIt> representing the submatches identified by the index values in the stored vector subs for each regular expression match.

An index value of -1 designates the character sequence beginning immediately after the end of the previous regular expression match, or beginning at the start of the character sequence if there was no previous regular expression match, and extending to but not including the first character of the current regular expression match, or to the end of the character sequence if there is no current match. Any other index value idx designates the contents of the capture group held in it.match[idx].

Header: <regex>

Namespace: std

Was this page helpful?
(1500 characters remaining)
Thank you for your feedback
© 2014 Microsoft