Namensräume
Varianten
Aktionen

std::regex_iterator

Aus cppreference.com
< cpp‎ | regex

 
 
Reguläre Ausdrücke Bibliothek
Classes
Original:
Classes
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
basic_regex(C++11)
sub_match(C++11)
match_results(C++11)
Algorithmen
Original:
Algorithms
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
regex_match(C++11)
regex_search(C++11)
regex_replace(C++11)
Iteratoren
Original:
Iterators
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
regex_iterator(C++11)
regex_token_iterator(C++11)
Ausnahmen
Original:
Exceptions
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
regex_error(C++11)
Traits
Original:
Traits
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
regex_traits(C++11)
Konstanten
Original:
Constants
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
syntax_option_type(C++11)
match_flag_type(C++11)
error_type(C++11)
 
template<

    class BidirIt,
    class CharT = typename std::iterator_traits<BidirIt>::value_type,
    class Traits = std::regex_traits<CharT>

> class regex_iterator
(seit C++11)
std::regex_iterator ist ein Nur-Lese-ForwardIterator, die die einzelnen Spiele eines regulären Ausdrucks greift innerhalb der zugrunde liegenden Zeichenfolge .
Original:
std::regex_iterator is a read-only ForwardIterator that accesses the individual matches of a regular expression within the underlying character sequence.
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
Auf dem Bau, und auf jedem Inkrement, ruft es std::regex_search und erinnert sich das Ergebnis (das heißt, speichert eine Kopie des Wertes std::match_results<BidirIt>). Der erste Gegenstand kann gelesen werden, wenn der Iterator konstruiert oder wenn die erste Dereferenzierung abgenommen werden kann. Ansonsten Dereferenzierung gibt nur eine Kopie des zuletzt erhaltenen Regex .
Original:
On construction, and on every increment, it calls std::regex_search and remembers the result (that is, saves a copy of the value std::match_results<BidirIt>). The first object may be read when the iterator is constructed or when the first dereferencing is done. Otherwise, dereferencing only returns a copy of the most recently obtained regex match.
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
Die default-konstruiert std::regex_iterator ist die End-of-sequence Iterator. Wenn eine gültige std::regex_iterator nach Erreichen des letzten Spiels (std::regex_search kehrt false) erhöht wird, wird es gleich dem End-of-sequence Iterator. Dereferenzierung oder Inkrementieren es weiter aufruft undefinierten Verhalten .
Original:
The default-constructed std::regex_iterator is the end-of-sequence iterator. When a valid std::regex_iterator is incremented after reaching the last match (std::regex_search returns false), it becomes equal to the end-of-sequence iterator. Dereferencing or incrementing it further invokes undefined behavior.
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
Eine typische Implementierung std::regex_iterator hält die Anfang und Ende Iteratoren für die zugrunde liegende Sequenz (zwei Instanzen von BidirIt), ein Zeiger auf den regulären Ausdruck (const regex_type*) und den Match-Flags (std::regex_constants::match_flag_type) und der aktuellen match (std::match_results<BidirIt>) .
Original:
A typical implementation of std::regex_iterator holds the begin and the end iterators for the underlying sequence (two instances of BidirIt), a pointer to the regular expression (const regex_type*) and the match flags (std::regex_constants::match_flag_type), and the current match (std::match_results<BidirIt>).
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.

Inhaltsverzeichnis

[Bearbeiten] Type Anforderungen

-
BidirIt must meet the requirements of BidirectionalIterator.

[Bearbeiten] Spezialisierungen

Mehrere Spezialisierungen für gemeinsame Zeichenfolge Typen sind definiert:
Original:
Several specializations for common character sequence types are defined:
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
Defined in header <regex>
Type
Original:
Type
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
Definition
cregex_iterator regex_iterator<const char*>
wcregex_iterator regex_iterator<const wchar_t*>
sregex_iterator regex_iterator<std::string::const_iterator>
wsregex_iterator regex_iterator<std::wstring::const_iterator>

[Bearbeiten] Mitglied Typen

Mitglied Typ
Original:
Member type
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
Definition
value_type std::match_results<BidirIt>
difference_type std::ptrdiff_t
pointer const value_type*
reference const value_type&
iterator_category std::forward_iterator_tag
regex_type basic_regex<CharT, Traits>

[Bearbeiten] Member-Funktionen

baut eine neue regex_iterator
Original:
constructs a new regex_iterator
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.

(öffentliche Elementfunktion)
(destructor)
(implizit deklariert)
destructs a regex_iterator, including the cached value
(öffentliche Elementfunktion)
ersetzt eine regex_iterator
Original:
replaces a regex_iterator
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.

(öffentliche Elementfunktion)
vergleicht zwei regex_iterators
Original:
compares two regex_iterators
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.

(öffentliche Elementfunktion)
Ruft einen Verweis auf die aktuelle match
accesses ein Mitglied der aktuellen Match
Original:
obtains a reference to the current match
accesses a member of the current match
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.

(öffentliche Elementfunktion)
Fortschritte der regex_iterator zum nächsten Treffer
Original:
advances the regex_iterator to the next match
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.

(öffentliche Elementfunktion)

[Bearbeiten] Notes

Es ist der Programmierer dafür verantwortlich, sicherzustellen, dass die std::basic_regex übergebene Objekt des Iterators Konstruktor den Iterator überlebt. Da der Iterator speichert einen Zeiger auf die regex, Inkrementieren der Iterator nach der regex wurde zerstört greift auf eine dangling Pointer .
Original:
It is the programmer's responsibility to ensure that the std::basic_regex object passed to the iterator's constructor outlives the iterator. Because the iterator stores a pointer to the regex, incrementing the iterator after the regex was destroyed accesses a dangling pointer.
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
Wenn das Teil des regulären Ausdrucks, die abgestimmt ist nur eine Behauptung (^, $, \b, \B), ist das Spiel in der Iterator gespeichert eine Null-Länge übereinstimmen, dh match[0].first == match[0].second .
Original:
If the part of the regular expression that matched is just an assertion (^, $, \b, \B), the match stored in the iterator is a zero-length match, that is, match[0].first == match[0].second.
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.

[Bearbeiten] Beispiel

#include <regex>
#include <iterator>
#include <iostream>
 
int main()
{
    const std::string text = "Quick brown fox.";
 
    std::regex re("[^\\s]+");
    auto beg = std::sregex_iterator(text.begin(), text.end(), re);
    auto end = std::sregex_iterator();
 
    std::cout << "The number of words is " << std::distance(beg, end) << '\n';
}

Output:

The number of words is 3

[Bearbeiten] Siehe auch

identifiziert einen regulären Ausdruck, inkl. aller Unterseiten Ausdruck übereinstimmt
Original:
identifies one regular expression match, including all sub-expression matches
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.

(Klassen-Template) [edit]
prüfen, ob ein regulärer Ausdruck tritt überall in einem String
Original:
check if a regular expression occurs anywhere within a string
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.

(Funktions-Template)