Espaces de noms
Variantes

std::regex_token_iterator

De cppreference.com

<metanoindex/>

 
 
Regular expressions bibliothèque
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)
Algorithmes
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)
Les itérateurs
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)
Exceptions
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)
Constantes
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)
 
<tbody> </tbody>
template< class BidirIt, class CharT = typename std::iterator_traits<BidirIt>::value_type, class Traits = std::regex_traits<CharT> > class regex_token_iterator
(depuis C++11)
std::regex_token_iterator est un ForwardIterator en lecture seule qui permet d'accéder aux différents sous-correspondances de chaque match d'une expression régulière dans la chaîne de caractères sous-jacent. Il peut également être utilisé pour accéder aux parties de la séquence qui n'ont pas été correspondant à l'expression rationnelle donnée (par exemple, en tant que 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.
Sur la construction, il construit un std::regex_iterator et sur chaque incrément à mesure qu'il progresse à travers les sous-correspondances demandées par les match_results actuelles, l'incrémentation du regex_iterator sous-jacente lors de l'incrémentation loin de la submatch dernière .
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.
La valeur par défaut est construit std::regex_token_iterator l'itérateur de fin de séquence. Quand un std::regex_token_iterator valide est incrémenté après avoir atteint le dernier sous-correspondance du jeu, il devient égal à l'itérateur de fin de séquence. Déréférencement ou l'incrémentant invoque par ailleurs un comportement indéfini .
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.
Juste avant de devenir l'itérateur de fin de séquence, une std::regex_token_iterator peut devenir un itérateur' suffixe, si l'indice -1 (non apparié fragment) apparaît dans la liste des indices submatch demandés. Un tel itérateur, si déréférencé, retourne un match_results correspondant à la séquence de caractères entre le dernier match et la fin de la séquence .
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.
Une application typique de std::regex_token_iterator maintient le std::regex_iterator sous-jacent, un récipient (par exemple std::vector<int>) des indices de sous-correspondance demandées, le compteur interne égal à l'indice de la sous-correspondance, un pointeur vers std::match_results, montrant le sous-correspondance actuelle de la correspondance actuelle, et une std::match_results objet contenant la séquence du dernier caractère non appariée (utilisé en mode 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.

Exigences de type

-
BidirIt must meet the requirements of BidirectionalIterator.

Spécialisations

Plusieurs spécialisations pour les types courants de séquence de caractères sont définies:
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 d'
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>

Types de membres

Type du membre Définition
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>

Fonctions membres

construit un nouveau 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.

(fonction membre publique)
(destructeur)
(implicitement déclaré)
destructs a regex_token_iterator, including the cached value
(fonction membre publique)
remplace 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.

(fonction membre publique)
compare deux 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.

(fonction membre publique)
accsses submatch courant
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.

(fonction membre publique)
les progrès de la regex_token_iterator à la sous-correspondance suivante
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.

(fonction membre publique)

Notes

Il est de la responsabilité du programmeur de s'assurer que l'objet std::basic_regex passé au constructeur de l'itérateur survit à l'itérateur. Parce que l'itérateur stocke une std::regex_iterator qui stocke un pointeur vers la regex, l'incrémentation de l'itérateur après les résultats de la regex a été détruit à un comportement indéfini .
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.

Exemple

#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"));
}

Résultat :

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