std::regex_match
De cppreference.com
<metanoindex/>
<tbody> </tbody>| Definido no cabeçalho <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 se existe uma correspondência entre o
e expressão regular e a sequência de caracteres inteiro [first,last) alvo, tendo em conta o efeito da flags. Os resultados da competição são retornados em 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.
You can help to correct and verify the translation. Click here for instructions.
2)
Comporta-se como (1) acima, omitindo os resultados dos jogos.
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.
You can help to correct and verify the translation. Click here for instructions.
3)
Retorna
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.
You can help to correct and verify the translation. Click here for instructions.
4)
Retorna
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.
You can help to correct and verify the translation. Click here for instructions.
5)
Retorna
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.
You can help to correct and verify the translation. Click here for instructions.
6)
Retorna
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.
You can help to correct and verify the translation. Click here for instructions.
Parâmetros
| first, last | - | a gama de caracteres de destino para aplicar o regex, dado 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 | - | os resultados dos jogos
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 | - | a seqüência alvo, dado como terminada em nulo seqüência C-estilo
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 | - | a cadeia alvo, dado como um 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 | - | a expressão 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 | - | bandeiras usado para determinar como o jogo será realizado
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.
| ||
Valor de retorno
Retorna
true se existe uma correspondência, false contrário. Em ambos os casos, o objecto m é actualizado, como se segue: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.
You can help to correct and verify the translation. Click here for instructions.
Se o jogo não 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.
You can help to correct and verify the translation. Click here for instructions.
m.ready() == true
| |
m.empty() == true
| |
m.size() == 0
|
Se o jogo 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.
You can help to correct and verify the translation. Click here for instructions.
m.ready()
|
true
|
m.empty()
|
false
|
m.size()
|
número de subexpressões mais um, isto é,
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 (o prefixo jogo está vazia) 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 (o sufixo jogo está vazia) 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 a seqüência é correspondido)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
|
o início da sequência que combinava com sub-expressão n, ou
last se a subexpressão não participou da partidaOriginal: the start of the sequence that matched sub-expression n, or last if the subexpression did not participate in the matchThe text has been machine-translated via Google Translate. You can help to correct and verify the translation. Click here for instructions. |
m[n].second
|
o fim da sequência que combinava com sub-expressão n, ou
last se a subexpressão não participou da partidaOriginal: the end of the sequence that matched sub-expression n, or last if the subexpression did not participate in the matchThe 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 se expressão sub-n participou no jogo, false contrárioOriginal: true if sub-expression n participated in the match, false otherwiseThe text has been machine-translated via Google Translate. You can help to correct and verify the translation. Click here for instructions. |
Exemplo
#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';
}
}
Saída:
foo.txt: 1
bar.txt: 1
zoidberg: 0
