public member function
<regex>
const value_type& operator*() const;
Dereference regex_iterator
Returns a reference to the match_results object the iterator is pointing to.
This operator shall not be applied to end-of-sequence iterators (the behavior of such an operation is undefined).
regex_iterator objects keep a match_results object internally whose reference is returned by a call to this function. The value of this object may be modified by a call to either operator++ or operator= on the regex_iterator object.
Example
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20
|
// regex_iterator example
#include <iostream>
#include <string>
#include <regex>
int main ()
{
std::string s ("this subject has a submarine as a subsequence");
std::regex e ("\\b(sub)([^ ]*)"); // matches words beginning by "sub"
std::regex_iterator<std::string::iterator> rit ( s.begin(), s.end(), e );
std::regex_iterator<std::string::iterator> rend;
while (rit!=rend) {
std::cout << (*rit).str() << std::endl;
++rit;
}
return 0;
}
| |
Output:
subject
submarine
subsequence
|