Was this page helpful?
Your feedback about this content is important. Let us know what you think.
Additional feedback?
1500 characters remaining
regex_token_iterator::regex_token_iterator

regex_token_iterator::regex_token_iterator

Constructs the iterator.

regex_token_iterator();
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 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);

first

Beginning of sequence to match.

last

End of sequence to match.

re

Regular expression for matches.

f

Flags for matches.

The first constructor constructs an end-of-sequence iterator.

The second constructor constructs an object whose stored iterator it is initialized to regex_iterator<BidIt, Elem, RXtraits>(first, last, re, f), whose stored vector subs holds exactly one integer, with value submatch, and whose stored value pos is zero. Note: the resulting object extracts the submatch identified by the index value submatch for each successful regular expression match.

The third constructor constructs an object whose stored iterator it is initialized to regex_iterator<BidIt, Elem, RXtraits>(first, last, re, f), whose stored vector subs holds a copy of the constructor argument submatches, and whose stored value pos is zero.

The fourth constructor constructs an object whose stored iterator it is initialized to regex_iterator<BidIt, Elem, RXtraits>(first, last, re, f), whose stored vector subs holds the N values pointed to by the constructor argument submatches, and whose stored value pos is zero.

 

// std_tr1__regex__regex_token_iterator_construct.cpp 
// compile with: /EHsc 
#include <regex> 
#include <iostream> 
 
typedef std::tr1::regex_token_iterator<const char *> Myiter; 
int main() 
    { 
    const char *pat = "aaxaayaaz"; 
    Myiter::regex_type rx("(a)a"); 
    Myiter next(pat, pat + strlen(pat), rx); 
    Myiter end; 
 
// show whole match 
    for (; next != end; ++next) 
        std::cout << "match == " << next->str() << std::endl; 
    std::cout << std::endl; 
 
// show prefix before match 
    next = Myiter(pat, pat + strlen(pat), rx, -1); 
    for (; next != end; ++next) 
        std::cout << "match == " << next->str() << std::endl; 
    std::cout << std::endl; 
 
// show (a) submatch only 
    next = Myiter(pat, pat + strlen(pat), rx, 1); 
    for (; next != end; ++next) 
        std::cout << "match == " << next->str() << std::endl; 
    std::cout << std::endl; 
 
// show prefixes and submatches 
    std::vector<int> vec; 
    vec.push_back(-1); 
    vec.push_back(1); 
    next = Myiter(pat, pat + strlen(pat), rx, vec); 
    for (; next != end; ++next) 
        std::cout << "match == " << next->str() << std::endl; 
    std::cout << std::endl; 
 
// show prefixes and whole matches 
    int arr[] = {-1, 0}; 
    next = Myiter(pat, pat + strlen(pat), rx, arr); 
    for (; next != end; ++next) 
        std::cout << "match == " << next->str() << std::endl; 
    std::cout << std::endl; 
 
// other members 
    Myiter it1(pat, pat + strlen(pat), rx); 
    Myiter it2(it1); 
    next = it1; 
 
    Myiter::iterator_category cat = std::forward_iterator_tag(); 
    Myiter::difference_type dif = -3; 
    Myiter::value_type mr = *it1; 
    Myiter::reference ref = mr; 
    Myiter::pointer ptr = &ref; 
 
    dif = dif; // to quiet "unused" warnings 
    ptr = ptr; 
 
    return (0); 
    } 
 
match == aa match == aa match == aa match == match == x match == y match == z match == a match == a match == a match == match == a match == x match == a match == y match == a match == z match == match == aa match == x match == aa match == y match == aa match == z

Header: <regex>

Namespace: std::tr1

Community Additions

ADD
Show:
© 2015 Microsoft