The Wayback Machine - https://web.archive.org/web/20180604214336/http://it.cppreference.com:80/w/cpp/regex/regex_token_iterator

std::regex_token_iterator

Da cppreference.com.
< cpp‎ | regex

 
 
Espressioni regolari libreria
Classi
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)
Algoritmi
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)
Iteratori
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)
Eccezioni
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)
Tratti
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)
Costanti
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 =typenamestd::iterator_traits<BidirIt>::value_type,
    class Traits =std::regex_traits<CharT>

>class regex_token_iterator
(dal C++11)
std::regex_token_iterator è di sola lettura ForwardIterator che accede ai singoli sub-partite di tutte le partite di una espressione regolare all'interno della sequenza di caratteri di base. Può anche essere utilizzato per accedere alle parti della sequenza che non sono stati trovati dalla data espressione regolare (ad esempio come tokenizer).
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.
In costruzione, costruisce un std::regex_iterator e su ogni incremento che passi attraverso le richieste sub-partite da match_results le correnti, incrementando il regex_iterator sottostante quando l'incremento di distanza dal submatch ultimo.
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.
L'impostazione predefinita-costruito std::regex_token_iterator è la fine-di-sequenza di iteratore. Quando un std::regex_token_iterator valida viene incrementato dopo aver raggiunto l'ultimo submatch dell'ultimo match, diventa uguale al fine sequenza iteratore. Dereferenziazione o incrementarlo richiede ulteriori comportamento indefinito.
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.
Appena prima di diventare di fine-sequenza iteratore, un std::regex_token_iterator può diventare un suffisso' iteratore, se l'indice -1 (non appaiato frammento) appare nell'elenco degli indici submatch richiesti. Tale iteratore, se dereferenced, restituisce un match_results corrispondenti alla sequenza di caratteri tra l'ultima partita e la fine della sequenza.
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.
Una tipica implementazione di std::regex_token_iterator tiene la std::regex_iterator sottostante, un contenitore (ad esempio std::vector<int>) degli indici submatch richiesti, il contatore interno uguale all'indice della submatch, un puntatore a std::match_results, indicando il submatch corrente della corrispondenza corrente, e un std::match_results oggetto contenente l'ultimo non appaiato sequenza di caratteri (utilizzato in modalità tokenizer).
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.

Indice

[modifica]Tipo requisiti

-
BidirIt must meet the requirements of BidirectionalIterator.

[modifica]Specializzazioni

Diverse specializzazioni per i tipi più comuni sequenze di caratteri sono definiti:
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>
Tipo
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_iteratorregex_token_iterator<constchar*>
wcregex_token_iteratorregex_token_iterator<constwchar_t*>
sregex_token_iteratorregex_token_iterator<std::string::const_iterator>
wsregex_token_iteratorregex_token_iterator<std::wstring::const_iterator>

[modifica]Membri tipi

Membro tipo
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_typestd::sub_match<BidirIt>
difference_typestd::ptrdiff_t
pointerconst value_type*
referenceconst value_type&
iterator_categorystd::forward_iterator_tag
regex_typebasic_regex<CharT, Traits>

[modifica]Membri funzioni

costruisce un nuovo 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.

(metodo pubblico)
(destructor)
(dichiarato in modo implicito)
destructs a regex_token_iterator, including the cached value
(metodo pubblico)
sostituisce un 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.

(metodo pubblico)
confronta due 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.

(metodo pubblico)
accsses submatch corrente
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.

(metodo pubblico)
avanza il regex_token_iterator al submatch successivo
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.

(metodo pubblico)

[modifica]Note

E 'responsabilità del programmatore garantire che l'oggetto std::basic_regex passato al costruttore dell'iteratore sopravvive l'iteratore. Poiché l'iteratore memorizza un std::regex_iterator che memorizza un puntatore alla regex, incrementando l'iteratore dopo i risultati la regex è stato distrutto in un comportamento indefinito.
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.

[modifica]Esempio

#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+");// whitespacestd::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 submatchesstd::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
close