Espaces de noms
Variantes
Actions

std::regex_match

De cppreference.com
< cpp‎ | regex

 
 
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)
 
Déclaré dans l'en-tête <regex>
template<class BidirIt,

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

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

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

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

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

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

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

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

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

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

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

                      std::regex_constants::match_default);
(6) (depuis C++11)
1)
Détermine s'il ya un match entre le e expression régulière et la séquence cible tout caractère [first,last), en tenant compte de l'effet de flags. Les résultats des matchs sont retournés dans 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 comporte comme (1) ci-dessus, en omettant les résultats des matchs .
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)
Retours 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)
Retours 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)
Retours 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)
Retours 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.

Sommaire

[modifier]Paramètres

first, last -
la plage de caractères cible d'appliquer la regex, étant donné que les itérateurs
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 -
les résultats des matchs
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 chaîne cible, donné comme un zéro terminal C de style chaîne
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 chaîne cible, donné comme un 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 -
l'expression régulière
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 -
indicateurs utilisés pour déterminer comment le match va être effectuée
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.

[modifier]Retourne la valeur

Retours true si une correspondance existe, false autrement. Dans les deux cas, l'objet est mis à jour m, comme suit:
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 le match n'existe pas:
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 le match 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()
nombre de sous-expressions plus 1, c'est-à-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().firstfirst
m.prefix().secondfirst
m.prefix().matched
false (le préfixe match est vide)
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().firstlast
m.suffix().secondlast
m.suffix().matched
false (le suffixe match est vide)
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].firstfirst
m[0].secondlast
m[0].matched
true (la séquence entière est apparié)
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
le début de la séquence qui correspondait à la sous-expression n, ou last si la sous-expression n'a pas participé à la rencontre
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
la fin de la séquence qui correspondait à la sous-expression n, ou last si la sous-expression n'a pas participé à la rencontre
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 la sous-expression n ont participé à la rencontre, false autrement
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.

[modifier]Exemple

#include <iostream>#include <string>#include <regex>   int main(){std::string fnames[]={"foo.txt", "bar.txt", "zoidberg"};   std::regex txt_regex("[a-z]+\\.txt");for(constauto&fname : fnames){std::cout<< fname <<": "<< std::regex_match(fname, txt_regex)<<'\n';}}

Résultat :

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

[modifier]Voir aussi

(C++11)
objet expression régulière
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.

(classe générique)[edit]
identifie une correspondance d'expression régulière, y compris tous les matchs de la sous-expression
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.

(classe générique)[edit]
close