Espacios de nombres
Variantes
Acciones

std::regex_token_iterator

De cppreference.com
< cpp‎ | regex

 
 
Expresiones biblioteca Regular
Clases
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)
Algoritmos
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)
Los iteradores
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)
Excepciones
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)
Rasgos
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)
 
template<

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

> class regex_token_iterator
(desde C++11)
std::regex_token_iterator es un ForwardIterator de sólo lectura que accede a los distintos sub-matches de todos los partidos de una expresión regular dentro de la secuencia de caracteres subyacente. También se puede utilizar para acceder a las partes de la secuencia que no se correspondían con la expresión regular dada (por ejemplo, como un señalizador) .
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.
En la construcción, se construye un std::regex_iterator y en cada incremento que los pasos a través de los solicitados sub-partidos de los match_results actuales, incrementando el regex_iterator subyacente al incrementar la distancia de subcoincidencia pasado .
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.
El valor predeterminado construido std::regex_token_iterator es el iterador de final de secuencia. Cuando un std::regex_token_iterator válido se incrementa después de alcanzar la subcoincidencia última de la última coincidencia, se hace igual a la iterador de final de secuencia. Desreferenciación o incrementarlo aún más invoca un comportamiento indefinido .
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.
Justo antes de convertirse en el iterador de fin de secuencia, un std::regex_token_iterator puede convertirse en un sufijo' iterador, si el índice -1 (no concordancia fragmento) aparece en la lista de los índices Subpartido solicitados. Iterador tal, si desreferenciado, devuelve un match_results correspondientes a la secuencia de caracteres entre la última coincidencia y el final de la secuencia .
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 implementación típica de std::regex_token_iterator sostiene el std::regex_iterator subyacente, un recipiente (por ejemplo std::vector<int>) de los índices Subpartido solicitados, el contador interno igual al índice de la subcoincidencia, un puntero a std::match_results, que señala en la subcoincidencia actual de la partida actual, y un std::match_results objeto que contiene el último no-concordancia secuencia de caracteres (se utiliza en el modo de 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.

Contenido

[editar] Tipo de requisitos

-
BidirIt must meet the requirements of BidirectionalIterator.

[editar] Especializaciones

Varias especializaciones comunes para los tipos de caracteres de secuencia se definen:
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_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>

[editar] Tipos de miembros

Miembro de 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_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>

[editar] Las funciones miembro

construye una nueva 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.

(miembro público función)
(destructor)
(implícitamente declarado)
destructs a regex_token_iterator, including the cached value
(miembro público función)
sustituye a 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.

(miembro público función)
compara dos 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.

(miembro público función)
accsses subcoincidencia actual
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.

(miembro público función)
avanza la regex_token_iterator a la subcoincidencia siguiente
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.

(miembro público función)

[editar] Notas

Es responsabilidad del programador asegurarse de que el objeto std::basic_regex pasa al constructor del iterador sobrevive el iterador. Debido a que el iterador guarda una std::regex_iterator que almacena un puntero a la expresión regular, incrementar el iterador después de los resultados de la expresión regular fue destruido en un comportamiento no definido .
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.

[editar] Ejemplo

#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