Espacios de nombres
Variantes
Acciones

std::regex_match

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)
 
Defined in header <regex>
template< class BidirIt,

          class Alloc, class CharT, class Traits >
bool regex_match( BidirIt first, BidirIt last,
                  std::match_results<BidirIt,Alloc>& m,
                  const std::basic_regex<CharT,Traits>& e,
                  std::regex_constants::match_flag_type flags =

                      std::regex_constants::match_default );
(1) (desde C++11)
template< class BidirIt,

          class CharT, class Traits >
bool regex_match( BidirIt first, BidirIt last,
                  const std::basic_regex<CharT,Traits>& e,
                  std::regex_constants::match_flag_type flags =

                      std::regex_constants::match_default );
(2) (desde C++11)
template< class CharT, class Alloc, class Traits >

bool regex_match( const CharT* str,
                  std::match_results<const CharT*,Alloc>& m,
                  const std::basic_regex<CharT,Traits>& e,
                  std::regex_constants::match_flag_type flags =

                      std::regex_constants::match_default );
(3) (desde C++11)
template< class STraits, class SAlloc,

          class Alloc, class CharT, class Traits >
bool regex_match( const std::basic_string<CharT,STraits,SAlloc>& s,
                  std::match_results<
                      typename std::basic_string<CharT,STraits,SAlloc>::const_iterator,
                      Alloc
                  >& m,
                  const std::basic_regex<CharT,Traits>& e,
                  std::regex_constants::match_flag_type flags =

                      std::regex_constants::match_default );
(4) (desde C++11)
template< class CharT, class Traits >

bool regex_match( const CharT* str,
                  const std::basic_regex<CharT,Traits>& e,
                  std::regex_constants::match_flag_type flags =

                      std::regex_constants::match_default );
(5) (desde C++11)
template< class STraits, class SAlloc,

          class CharT, class Traits >
bool regex_match( const std::basic_string<CharT, STraits, SAlloc>& s,
                  const std::basic_regex<CharT,Traits>& e,
                  std::regex_constants::match_flag_type flags =

                      std::regex_constants::match_default );
(6) (desde C++11)
1)
Determina si hay una coincidencia entre la e expresión regular y la secuencia de caracteres de destino [first,last) todo, teniendo en cuenta el efecto de flags. Resultados de los partidos se devuelven en m .
Original:
Determines if there is a match between the regular expression e and the entire target character sequence [first,last), taking into account the effect of flags. Match results are returned in m.
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
2)
Se comporta como (1) anterior, omitiendo los resultados de los partidos .
Original:
Behaves as (1) above, omitting the match results.
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
3)
Devoluciones std::regex_match(str, str + std::char_traits<charT>::length(str), m, e, flags) .
Original:
Returns std::regex_match(str, str + std::char_traits<charT>::length(str), m, e, flags).
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
4)
Devoluciones std::regex_match(s.begin(), s.end(), m, e, flags) .
Original:
Returns std::regex_match(s.begin(), s.end(), m, e, flags).
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
5)
Devoluciones std::regex_match(str, str + std::char_traits<charT>::length(str), e, flags) .
Original:
Returns std::regex_match(str, str + std::char_traits<charT>::length(str), e, flags).
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
6)
Devoluciones std::regex_match(s.begin(), s.end(), e, flags) .
Original:
Returns std::regex_match(s.begin(), s.end(), e, flags).
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.

Contenido

[editar] Parámetros

first, last -
el intervalo de caracteres de destino para aplicar la expresión regular para, da como iteradores
Original:
the target character range to apply the regex to, given as iterators
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
m -
los resultados de los partidos
Original:
the match results
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
str -
la cadena de destino, teniendo en cuenta como terminada en nulo de C-estilo cadena
Original:
the target string, given as a null-terminated C-style string
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
s -
la cadena de destino, teniendo en cuenta como std::basic_string
Original:
the target string, given as a std::basic_string
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
e -
la expresión regular
Original:
the regular expression
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
flags -
indicadores utilizados para determinar cómo el partido se llevará a cabo
Original:
flags used to determine how the match will be performed
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
Type requirements
-
BidirIt must meet the requirements of BidirectionalIterator.

[editar] Valor de retorno

Devoluciones true si existe una coincidencia, false lo contrario. En cualquier caso, la m objeto se actualiza, como sigue:
Original:
Returns true if a match exists, false otherwise. In either case, the object m is updated, as follows:
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
Si el partido no existe:
Original:
If the match does not exist:
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
m.ready() == true
m.empty() == true
m.size() == 0
Si el partido existe:
Original:
If the match exists:
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
m.ready() true
m.empty() false
m.size()
número de subexpresiones más 1, es decir, 1+e.mark_count()
Original:
number of subexpressions plus 1, that is, 1+e.mark_count()
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
m.prefix().first first
m.prefix().second first
m.prefix().matched
false (el prefijo partido está vacío)
Original:
false (the match prefix is empty)
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
m.suffix().first last
m.suffix().second last
m.suffix().matched
false (el sufijo partido está vacío)
Original:
false (the match suffix is empty)
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
m[0].first first
m[0].second last
m[0].matched
true (toda la secuencia se empareja)
Original:
true (the entire sequence is matched)
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
m[n].first
el inicio de la secuencia que hacía juego con sub-expresión n, o last si la subexpresión no participó en el partido
Original:
the start of the sequence that matched sub-expression n, or last if the subexpression did not participate in the match
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
m[n].second
Al final de la secuencia que hacía juego con sub-expresión n, o last si la subexpresión no participó en el partido
Original:
the end of the sequence that matched sub-expression n, or last if the subexpression did not participate in the match
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
m[n].matched
true si subexpresión n participaron en el encuentro, false lo contrario
Original:
true if sub-expression n participated in the match, false otherwise
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 <iostream>
#include <string>
#include <regex>
 
int main()
{
    std::string fnames[] = {"foo.txt", "bar.txt", "zoidberg"};
 
    std::regex txt_regex("[a-z]+\\.txt");
    for (const auto &fname : fnames) {
        std::cout << fname << ": " << std::regex_match(fname, txt_regex) << '\n';
    }
}

Output:

foo.txt: 1
bar.txt: 1
zoidberg: 0

[editar] Ver también

objeto de expresión regular
Original:
regular expression object
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.

(clase de plantilla) [edit]
identifica una coincidencia de expresión regular, incluyendo todos los partidos de sub-expresión
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.

(clase de plantilla) [edit]