| Localization library | |||||||||||||||||||||||||
| Regular expressions library(C++11) | |||||||||||||||||||||||||
| Formatting library(C++20) | |||||||||||||||||||||||||
| Null-terminated sequence utilities | |||||||||||||||||||||||||
| Byte strings | |||||||||||||||||||||||||
| Multibyte strings | |||||||||||||||||||||||||
| Wide strings | |||||||||||||||||||||||||
| Primitive numeric conversions | |||||||||||||||||||||||||
| |||||||||||||||||||||||||
| Text encoding identifications | |||||||||||||||||||||||||
| |||||||||||||||||||||||||
| Classes | ||||
(C++11) | ||||
(C++11) | ||||
(C++11) | ||||
| Algorithms | ||||
(C++11) | ||||
(C++11) | ||||
(C++11) | ||||
| Iterators | ||||
(C++11) | ||||
(C++11) | ||||
| Exceptions | ||||
(C++11) | ||||
| Traits | ||||
(C++11) | ||||
| Constants | ||||
(C++11) | ||||
(C++11) | ||||
(C++11) | ||||
| Regex Grammar | ||||
(C++11) |
| Member functions | ||||
regex_iterator::regex_iterator | ||||
| Comparisons | ||||
(until C++20) | ||||
| Observers | ||||
| Modifiers | ||||
regex_iterator(); | (1) | (since C++11) |
regex_iterator( BidirIt a, BidirIt b, const regex_type& re, | (2) | (since C++11) |
regex_iterator(const regex_iterator&); | (3) | (since C++11) |
regex_iterator( BidirIt, BidirIt, const regex_type&&, | (4) | (since C++11) |
Constructs a newregex_iterator:
regex_iterator from the sequence of characters[a, b), the regular expressionre, and a flagm that governs matching behavior. This constructor performs an initial call tostd::regex_search with this data. If the result of this initial call isfalse,*this is set to an end-of-sequence iterator.regex_iterator.| a | - | LegacyBidirectionalIterator to the beginning of the target character sequence |
| b | - | LegacyBidirectionalIterator to the end of the target character sequence |
| re | - | regular expression used to search the target character sequence |
| m | - | flags that govern the behavior ofre |
#include <iostream>#include <regex>#include <string_view> int main(){constexprstd::string_view str{R"( #ONE: *p = &Mass; #Two: MOV %rd, 42 )"};conststd::regex re("[a-w]"); // create regex_iterator, overload (2)auto it=std::regex_iterator<std::string_view::iterator>{ str.cbegin(), str.cend(), re// re is lvalue; if an immediate expression was used// instead, e.g. std::regex{"[a-z]"}, this would// produce an error since overload (4) is deleted}; for(decltype(it) last/* overload (1) */; it!= last;++it)std::cout<<(*it).str();std::cout<<'\n';}
Output:
password
The following behavior-changing defect reports were applied retroactively to previously published C++ standards.
| DR | Applied to | Behavior as published | Correct behavior |
|---|---|---|---|
| LWG 2332 | C++11 | aregex_iterator constructed from a temporarybasic_regex became invalid immediately | such construction is disallowed via a deleted overload |