std::regex_replace
![]() |
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. |
Déclaré dans l'en-tête <regex>
|
||
template< class OutputIt, class BidirIt, class Traits, class CharT, |
(1) | (depuis C++11) |
template< class OutputIt, class BidirIt, class Traits, class CharT > |
(2) | (depuis C++11) |
template< class Traits, class CharT, class STraits, class SAlloc, |
(3) | (depuis C++11) |
template< class Traits, class CharT, class STraits, class SAlloc > |
(4) | (depuis C++11) |
template< class Traits, class CharT, class STraits, class SAlloc > |
(5) | (depuis C++11) |
template< class Traits, class CharT > std::basic_string<CharT> |
(6) | (depuis C++11) |
i
comme par std::regex_iterator<BidirIt, CharT, traits> i(first, last, e, flags), et l'utilise pour faire défiler tous les matches de e
dans le [first,last)
séquence. Pour chaque match de tels m
, copie la sous-séquence non appariée (m.prefix()
) dans out
comme ça, et puis remplace la sous-séquence correspond à la chaîne de remplacement formaté comme si en appelant m.format(out, fmt, flags). En l'absence de plus de correspondances sont trouvées, copie les autres non appariés caractères out
.i
as if by std::regex_iterator<BidirIt, CharT, traits> i(first, last, e, flags), and uses it to step through every match of e
within the sequence [first,last)
. For each such match m
, copies the non-matched subsequence (m.prefix()
) into out
as-is and then replaces the matched subsequence with the formatted replacement string as if by calling m.format(out, fmt, flags). When no more matches are found, copies the remaining non-matched characters to out
.You can help to correct and verify the translation. Click here for instructions.
out
-est .out
as-is.You can help to correct and verify the translation. Click here for instructions.
flags
contient std::regex_constants::format_no_copy, les séquences non appariées sont pas copiés dans out
.flags
contains std::regex_constants::format_no_copy, the non-matched subsequences are not copied into out
.You can help to correct and verify the translation. Click here for instructions.
flags
contient std::regex_constants::format_first_only, seule la première correspondance est remplacé .flags
contains std::regex_constants::format_first_only, only the first match is replaced.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.
result
de std::basic_string<CharT, ST, SA> type et appelle std::regex_replace(std::back_inserter(result), s.begin(), s.end(), e, fmt, flags) .result
of type std::basic_string<CharT, ST, SA> and calls std::regex_replace(std::back_inserter(result), s.begin(), s.end(), e, fmt, flags).You can help to correct and verify the translation. Click here for instructions.
result
de std::basic_string<CharT> type et appelle std::regex_replace(std::back_inserter(result), s, s + std::char_traits<CharT>::length(s), e, fmt, flags) .result
of type std::basic_string<CharT> and calls std::regex_replace(std::back_inserter(result), s, s + std::char_traits<CharT>::length(s), e, fmt, flags).You can help to correct and verify the translation. Click here for instructions.
Sommaire |
[modifier] Paramètres
first, last | - | la séquence de caractères d'entrée, représentée comme une paire d'itérateurs
Original: the input character sequence, represented as a pair of iterators The text has been machine-translated via Google Translate. You can help to correct and verify the translation. Click here for instructions. |
s | - | la séquence de caractères d'entrée, représenté comme std :: basic_string ou tableau de caractères
Original: the input character sequence, represented as std::basic_string or character array The text has been machine-translated via Google Translate. You can help to correct and verify the translation. Click here for instructions. |
e | - | le std :: basic_regex qui sera en correspondance avec la séquence d'entrée
Original: the std::basic_regex that will be matched against the input sequence The text has been machine-translated via Google Translate. You can help to correct and verify the translation. Click here for instructions. |
flags | - | les drapeaux du match de std::regex_constants::match_flag_type type
Original: the match flags of type std::regex_constants::match_flag_type The text has been machine-translated via Google Translate. You can help to correct and verify the translation. Click here for instructions. |
fmt | - | la chaîne regex format de remplacement, la syntaxe exacte dépend de la valeur de
flags Original: the regex replacement format string, exact syntax depends on the value of flags The text has been machine-translated via Google Translate. You can help to correct and verify the translation. Click here for instructions. |
out | - | itérateur de sortie pour stocker le résultat du remplacement
Original: output iterator to store the result of the replacement The text has been machine-translated via Google Translate. You can help to correct and verify the translation. Click here for instructions. |
Type requirements | ||
-OutputIt must meet the requirements of OutputIterator .
| ||
-BidirIt must meet the requirements of BidirectionalIterator .
|
[modifier] Retourne la valeur
out
.out
.You can help to correct and verify the translation. Click here for instructions.
result
la sortie .result
which contains the output.You can help to correct and verify the translation. Click here for instructions.
[modifier] Exceptions
You can help to correct and verify the translation. Click here for instructions.
[modifier] Exemple
#include <iostream> #include <regex> #include <string> int main() { std::string text = "Quick brown fox"; std::regex vowel_re("a|o|e|u|i"); std::cout << std::regex_replace(text, vowel_re, "[$&]") << '\n'; }
Résultat :
Q[u][i]ck br[o]wn f[o]x
[modifier] Voir aussi
(C++11) |
tente de faire correspondre une expression régulière de toute partie de la séquence de caractères Original: attempts to match a regular expression to any part of the character sequence The text has been machine-translated via Google Translate. You can help to correct and verify the translation. Click here for instructions. (fonction générique) |
(C++11) |
options spécifiques à l'appariement Original: options specific to matching The text has been machine-translated via Google Translate. You can help to correct and verify the translation. Click here for instructions. (typedef) |