Namensräume
Varianten
Aktionen

std::regex_token_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_token_iterator
(seit C++11)
std::regex_token_iterator ist ein Nur-Lese-ForwardIterator, die die einzelnen Sub-Spielen jedes Spiel eines regulären Ausdrucks innerhalb der zugrunde liegenden Zeichenfolge zugreift. Es kann auch verwendet werden, um die Teile der Sequenz, die nicht von der gegebenen regulären Ausdruck (zB als tokenizer) wurden abgestimmt zuzugreifen .
Original:
std::regex_token_iterator is a read-only ForwardIterator that accesses the individual sub-matches of every match of a regular expression within the underlying character sequence. It can also be used to access the parts of the sequence that were not matched by the given regular expression (e.g. as a tokenizer).
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
Am Aufbau konstruiert sie eine std::regex_iterator und an jedem Inkrement es schrittweise durch die angeforderte Sub-Spiele des aktuellen match_results, Inkrementieren des zugrundeliegenden regex_iterator beim Inkrementieren vom letzten Teilentsprechung .
Original:
On construction, it constructs an std::regex_iterator and on every increment it steps through the requested sub-matches from the current match_results, incrementing the underlying regex_iterator when incrementing away from the last submatch.
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_token_iterator ist die End-of-sequence Iterator. Wenn eine gültige std::regex_token_iterator nach Erreichen der letzten Teilentsprechung des letzten Spiels erhöht wird, wird es gleich der End-of-Sequenz Iterator. Dereferenzierung oder Inkrementieren es weiter aufruft undefinierten Verhalten .
Original:
The default-constructed std::regex_token_iterator is the end-of-sequence iterator. When a valid std::regex_token_iterator is incremented after reaching the last submatch of the last match, 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.
Gerade bevor die End-of-sequence Iterator kann ein std::regex_token_iterator a suffix Iterator zu werden, wenn der Index -1 (non-matched-Fragment) erscheint in der Liste der angeforderten Teilentsprechung Indizes. Solche Iterator, wenn dereferenziert, kehrt ein match_results entsprechend der Sequenz von Zeichen zwischen dem letzten Spiel und am Ende der Sequenz .
Original:
Just before becoming the end-of-sequence iterator, a std::regex_token_iterator may become a suffix iterator, if the index -1 (non-matched fragment) appears in the list of the requested submatch indexes. Such iterator, if dereferenced, returns a match_results corresponding to the sequence of characters between the last match and the end of sequence.
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_token_iterator hält den zugrundeliegenden std::regex_iterator, einem Behälter (zB std::vector<int>) der angeforderten Teilentsprechung Indizes, der interne Zähler gleich dem Index des Teilentsprechung, einen Zeiger auf std::match_results und zeigt auf dem aktuellen Teilentsprechung des laufenden Spiels, und ein std::match_results Objekt mit dem letzten nicht-passenden Zeichenfolge (in Tokenizer-Modus) .
Original:
A typical implementation of std::regex_token_iterator holds the underlying std::regex_iterator, a container (e.g. std::vector<int>) of the requested submatch indexes, the internal counter equal to the index of the submatch, a pointer to std::match_results, pointing at the current submatch of the current match, and a std::match_results object containing the last non-matched character sequence (used in tokenizer mode).
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_token_iterator regex_token_iterator<const char*>
wcregex_token_iterator regex_token_iterator<const wchar_t*>
sregex_token_iterator regex_token_iterator<std::string::const_iterator>
wsregex_token_iterator regex_token_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::sub_match<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_token_iterator
Original:
constructs a new regex_token_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_token_iterator, including the cached value
(öffentliche Elementfunktion)
ersetzt eine regex_token_iterator
Original:
replaces a regex_token_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_token_iterators
Original:
compares two regex_token_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)
accsses aktuellen Teilentsprechung
Original:
accsses current submatch
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_token_iterator zum nächsten Teilentsprechung
Original:
advances the regex_token_iterator to the next submatch
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 eine std::regex_iterator die einen Zeiger speichert die regex, Inkrementieren der Iterator nach der regex wurde zerstört Ergebnisse in undefinierten Verhalten .
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 std::regex_iterator which stores a pointer to the regex, incrementing the iterator after the regex was destroyed results in undefined behavior.
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 <fstream>
#include <iostream>
#include <algorithm>
#include <iterator>
#include <regex>
int main()
{
   std::string text = "Quick brown fox.";
   // tokenization (non-matched fragments)
   // Note that regex is matched only two times: when the third value is obtained
   // the iterator is a suffix iterator.
   std::regex ws_re("\\s+"); // whitespace
   std::copy( std::sregex_token_iterator(text.begin(), text.end(), ws_re, -1),
              std::sregex_token_iterator(),
              std::ostream_iterator<std::string>(std::cout, "\n"));
 
   // iterating the first submatches
   std::string html = "<p><a href=\"http://google.com\">google</a> "
                      "< a HREF =\"http://cppreference.com\">cppreference</a>\n</p>";
   std::regex url_re("<\\s*A\\s+[^>]*href\\s*=\\s*\"([^\"]*)\"", std::regex::icase);
   std::copy( std::sregex_token_iterator(html.begin(), html.end(), url_re, 1),
              std::sregex_token_iterator(),
              std::ostream_iterator<std::string>(std::cout, "\n"));
}

Output:

Quick
brown
fox.
http://google.com
http://cppreference.com