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. |
Definido no cabeçalho <regex>
|
||
template< class OutputIt, class BidirIt, class Traits, class CharT, |
(1) | (desde C++11) |
template< class OutputIt, class BidirIt, class Traits, class CharT > |
(2) | (desde C++11) |
template< class Traits, class CharT, class STraits, class SAlloc, |
(3) | (desde C++11) |
template< class Traits, class CharT, class STraits, class SAlloc > |
(4) | (desde C++11) |
template< class Traits, class CharT, class STraits, class SAlloc > |
(5) | (desde C++11) |
template< class Traits, class CharT > std::basic_string<CharT> |
(6) | (desde C++11) |
i
como se por std::regex_iterator<BidirIt, CharT, traits> i(first, last, e, flags), e usa-lo para percorrer todos os jogos de e
dentro do [first,last)
seqüência. Para cada partida m
tal, copia a subseqüência não-pareado (m.prefix()
) em out
como está e então substitui o subseqüência combinado com a cadeia de substituição formatado como se chamando m.format(out, fmt, flags). Quando não há mais jogos são encontrados, copia os restantes não emparelhadas caracteres para 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
como está.out
as-is.You can help to correct and verify the translation. Click here for instructions.
flags
contém std::regex_constants::format_no_copy, as subseqüências não emparelhadas não são copiadas para 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
contém std::regex_constants::format_first_only, apenas a primeira correspondência é substituído.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
seqüência vazia de std::basic_string<CharT, ST, SA> tipo e chama 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
seqüência vazia de std::basic_string<CharT> tipo e chama 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.
Índice |
[editar] Parâmetros
first, last | - | a seqüência de caracteres de entrada, representado como um par de iteradores
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 | - | a seqüência de caracteres de entrada, representado como basic_string std :: ou matriz de caracteres
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 | - | o std :: basic_regex que será comparado com a seqüência de entrada
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 | - | as bandeiras jogo de std::regex_constants::match_flag_type tipo
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 | - | a regex cadeia de formato de substituição, sintaxe exata depende do valor 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 | - | saída iterador para armazenar o resultado da substituição
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 .
|
[editar] Valor de retorno
out
.out
.You can help to correct and verify the translation. Click here for instructions.
result
string que contém a saída.result
which contains the output.You can help to correct and verify the translation. Click here for instructions.
[editar] Exceções
You can help to correct and verify the translation. Click here for instructions.
[editar] Exemplo
#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'; }
Saída:
Q[u][i]ck br[o]wn f[o]x
[editar] Veja também
(C++11) |
tentativas de correspondem a uma expressão regular para qualquer parte da seqüência de caracteres 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. (modelo de função) |
(C++11) |
opções específicas para correspondência 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) |