Constructs the iterator.

regex_iterator(BidIt first, BidIt last,
    const regex_type& re, regex_constants::match_flag_type f = regex_constants::match_default);


Beginning of sequence to match.


End of sequence to match.


Regular expression for matches.


Flags for matches.

The first constructor constructs an end-of-sequence iterator. The second constructor initializes the stored value begin with first, the stored value end with last, the stored value pregex with &re, and the stored value flags with f. It then calls regex_search(begin, end, match, *pregex, flags). If the search fails, the constructor sets the object to an end-of-sequence iterator.


// std_tr1__regex__regex_iterator_construct.cpp 
// compile with: /EHsc 
#include <regex> 
#include <iostream> 
typedef std::tr1::regex_iterator<const char *> Myiter; 
int main() 
    const char *pat = "axayaz"; 
    Myiter::regex_type rx("a"); 
    Myiter next(pat, pat + strlen(pat), rx); 
    Myiter end; 
    for (; next != end; ++next) 
        std::cout << "match == " << next->str() << 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 == a match == a match == a

Header: <regex>

Namespace: std::tr1

Community Additions