std::regex_constants::syntax_option_type
De cppreference.com
|
|
This page has been machine-translated from the English version of the wiki using Google Translate.
The translation may contain errors and awkward wording. Hover over text to see the original version. You can help to fix errors and improve the translation. For instructions click here. |
<metanoindex/>
<tbody> </tbody>| Déclaré dans l'en-tête <regex>
|
||
typedef /*unspecified*/ syntax_option_type; static constexpr syntax_option_type icase = /*unspecified*/; static constexpr syntax_option_type nosubs = /*unspecified*/; static constexpr syntax_option_type optimize = /*unspecified*/; static constexpr syntax_option_type collate = /*unspecified*/; static constexpr syntax_option_type ECMAScript = /*unspecified*/; static constexpr syntax_option_type basic = /*unspecified*/; static constexpr syntax_option_type extended = /*unspecified*/; static constexpr syntax_option_type awk = /*unspecified*/; static constexpr syntax_option_type grep = /*unspecified*/; static constexpr syntax_option_type egrep = /*unspecified*/; |
||
Le
syntax_option_type est un BitmaskType qui contient des options qui régissent la façon dont se comportent les expressions régulières .Original:
The
syntax_option_type is a BitmaskType that contains options that govern how regular expressions behave.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.
Les valeurs possibles pour ce type (
icase, optimize, etc) sont doublées à l'intérieur std :: basic_regex .Original:
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.
Constantes
Valeur
Original: Value The text has been machine-translated via Google Translate. You can help to correct and verify the translation. Click here for instructions. |
Effect(s) |
icase
|
Correspondance caractères doit être effectuée sans respecter la casse .
Original: Character matching should be performed without regard to case. The text has been machine-translated via Google Translate. You can help to correct and verify the translation. Click here for instructions. |
nosubs
|
Lors de l'exécution matchs, pas de matchs sous-expression doit être stocké dans la structure std::regex_match fourni .
Original: When performing matches, no sub-expression matches should be stored in the supplied std::regex_match structure. The text has been machine-translated via Google Translate. You can help to correct and verify the translation. Click here for instructions. |
optimize
|
Charge le moteur d'expressions régulières à faire correspondre plus rapidement, avec le coût potentiel de faire de la construction plus lente. Par exemple, cela pourrait signifier la conversion d'un FSA non-déterministe à une déterministe FSA .
Original: Instructs the regular expression engine to make matching faster, with the potential cost of making construction slower. For example, this might mean converting a non-deterministic FSA to a deterministic FSA. The text has been machine-translated via Google Translate. You can help to correct and verify the translation. Click here for instructions. |
collate
|
Les plages de caractères de la forme "[ab]" sera sensible locale .
Original: Character ranges of the form "[a-b]" will be locale sensitive. The text has been machine-translated via Google Translate. You can help to correct and verify the translation. Click here for instructions. |
ECMAScript
|
Utilisez le code ECMAScript (JavaScript) grammaire expression régulière (ECMA-262 grammar documentation), modifié pour supporter des éléments d'assemblage, les classes de personnages, et des classes d'équivalence de POSIX, et les alias de classes de caractères
\d, \D, \s, \S, \w et \W sont fabriqués locale-sensiblesOriginal: Use the ECMAScript (JavaScript) regular expression grammar (ECMA-262 grammar documentation), modified to support collating elements, character classes, and equivalence classes from POSIX, and the character class aliases \d, \D, \s, \S, \w, and \W are made locale-sensitiveThe text has been machine-translated via Google Translate. You can help to correct and verify the translation. Click here for instructions. |
basic
|
Utilisez la grammaire de base des expressions régulières POSIX (grammar documentation) .
Original: Use the basic POSIX regular expression grammar (grammar documentation). The text has been machine-translated via Google Translate. You can help to correct and verify the translation. Click here for instructions. |
extended
|
Utilisez la grammaire prolongée expression rationnelle POSIX (grammar documentation) .
Original: Use the extended POSIX regular expression grammar (grammar documentation). The text has been machine-translated via Google Translate. You can help to correct and verify the translation. Click here for instructions. |
awk
|
Utilisez la grammaire expression régulière utilisée par l'utilitaire awk' dans POSIX (grammar documentation)
Original: Use the regular expression grammar used by the awk utility in POSIX (grammar documentation) The text has been machine-translated via Google Translate. You can help to correct and verify the translation. Click here for instructions. |
grep
|
Utilisez la grammaire expression régulière utilisée par l'utilitaire grep' dans POSIX. C'est effectivement la même que l'option
basic avec l'ajout du saut de ligne '\ n' comme un séparateur d'alternance . Original: Use the regular expression grammar used by the grep utility in POSIX. This is effectively the same as the basic option with the addition of newline '\n' as an alternation separator. The text has been machine-translated via Google Translate. You can help to correct and verify the translation. Click here for instructions. |
egrep
|
Utilisez la grammaire expression régulière utilisée par l'utilitaire grep', avec l'option-E, dans POSIX. C'est effectivement la même que l'option
extended avec l'ajout du saut de ligne '\ n' comme un séparateur d'alternance dans addtion à «| '. Original: Use the regular expression grammar used by the grep utility, with the -E option, in POSIX. This is effectively the same as the extended option with the addition of newline '\n' as an alternation separator in addtion to '|'. The text has been machine-translated via Google Translate. You can help to correct and verify the translation. Click here for instructions. |
Notes
Parce que POSIX utilise "le plus long le plus à gauche" règle de correspondance (la sous-séquence la plus longue correspondance est trouvée, et si il ya plusieurs séquences telles, le premier est apparié), il n'est pas approprié, par exemple, pour analyser les langages de balisage: une regex POSIX comme
"<tag[^>]*>.*</tag>" correspondrait tout, de la première à la "<tag" "</tag>" dernière, y compris tous les "</tag>" et "<tag>" entre les deux. D'autre part, prend en charge ECMAScript non gourmandes matchs, et la spécification ECMAScript regex "<tag[^>]*>.*?</tag>" correspondrait seulement jusqu'à la première balise fermante .Original:
Because POSIX uses "leftmost longest" matching rule (the longest matching subsequence is matched, and if there are several such subsequences, the first one is matched), it is not suitable, for example, for parsing markup languages: a POSIX regex such as
"<tag[^>]*>.*</tag>" would match everything from the first "<tag" to the last "</tag>", including every "</tag>" and "<tag>" inbetween. On the other hand, ECMAScript supports non-greedy matches, and the ECMAScript regex "<tag[^>]*>.*?</tag>" would match only until the first closing tag.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.
Exemple
Illustre la différence de l'algorithme d'appariement entre ECMAScript et les expressions rationnelles POSIX
Original:
Illustrates the difference in the matching algorithm between ECMAScript and POSIX regular expressions
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.
#include <iostream>
#include <string>
#include <regex>
int main()
{
std::string str = "zzxayyzz";
std::regex re1(".*(a|xayy)"); // ECMA
std::regex re2(".*(a|xayy)", std::regex::extended); // POSIX
std::cout << "Searching for .*(a|xayy) in zzxayyzz:\n";
std::smatch m;
std::regex_search(str, m, re1);
std::cout << " ECMA (depth first search) match: " << m[0] << '\n';
std::regex_search(str, m, re2);
std::cout << " POSIX (leftmost longest) match: " << m[0] << '\n';
}
Résultat :
Searching for .*(a|xayy) in zzxayyzz:
ECMA (depth first search) match: zzxa
POSIX (leftmost longest) match: zzxayy
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) |