Espacios de nombres
Variantes
Acciones

std::regex_replace

De cppreference.com
< cpp‎ | regex

 
 
Expresiones biblioteca Regular
Clases
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)
Algoritmos
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)
Los iteradores
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)
Excepciones
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)
Rasgos
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)
 
Defined in header <regex>
template< class OutputIt, class BidirIt,

          class Traits, class CharT,
          class STraits, class SAlloc >
OutputIt regex_replace( OutputIt out, BidirIt first, BidirIt last,
                        const std::basic_regex<CharT,Traits>& e,
                        const std::basic_string<CharT,STraits,SAlloc>& fmt,
                        std::regex_constants::match_flag_type flags =

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

          class Traits, class CharT >
OutputIt regex_replace( OutputIt out, BidirIt first, BidirIt last,
                        const std::basic_regex<CharT,Traits>& e,
                        const CharT* fmt,
                        std::regex_constants::match_flag_type flags =

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

          class STraits, class SAlloc,
          class FTraits, class FAlloc >
std::basic_string<CharT,STraits,SAlloc>
    regex_replace( const std::basic_string<CharT,STraits,SAlloc>& s,
                   const std::basic_regex<CharT,Traits>& e,
                   const std::basic_string<CharT,FTraits,FAlloc>& fmt,
                   std::regex_constants::match_flag_type flags =

                       std::regex_constants::match_default );
(3) (desde C++11)
template< class Traits, class CharT,

          class STraits, class SAlloc >
std::basic_string<CharT,STraits,SAlloc>
    regex_replace( const std::basic_string<CharT,STraits,SAlloc>& s,
                   const std::basic_regex<CharT,Traits>& e,
                   const CharT* fmt,
                   std::regex_constants::match_flag_type flags =

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

          class STraits, class SAlloc >
std::basic_string<CharT>
    regex_replace( const CharT* s,
                   const std::basic_regex<CharT,Traits>& e,
                   const std::basic_string<CharT,STraits,SAlloc>& fmt,
                   std::regex_constants::match_flag_type flags =

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

std::basic_string<CharT>
    regex_replace( const CharT* s,
                   const std::basic_regex<CharT,Traits>& e,
                   const CharT* fmt,
                   std::regex_constants::match_flag_type flags =

                       std::regex_constants::match_default );
(6) (desde C++11)
1)
Construye un objeto std::regex_iterator i como por std::regex_iterator<BidirIt, CharT, traits> i(first, last, e, flags), y lo utiliza para desplazarse por todos los partidos del e en el [first,last) secuencia. Para cada partido m tal, no copia la subsecuencia de concordancia (m.prefix()) en out tal cual y luego reemplaza la subsecuencia corresponde con la cadena de reemplazo con formato como si se aplicase m.format(out, fmt, flags). Cuando no hay más partidos se encuentran, copia los restantes no pareados personajes out .
Original:
Constructs a std::regex_iterator object 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.
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
Si no hay coincidencias, copia la secuencia entera en out tal cual .
Original:
If there are no matches, copies the entire sequence into out as-is.
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
Si flags contiene std::regex_constants::format_no_copy, las subsecuencias no apareados no se copian en out .
Original:
If flags contains std::regex_constants::format_no_copy, the non-matched subsequences are not copied into out.
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
Si flags contiene std::regex_constants::format_first_only, sólo el primer partido se sustituye .
Original:
If flags contains std::regex_constants::format_first_only, only the first match is replaced.
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
2)
lo mismo que 1), pero la sustitución con formato se realiza como si se aplicase m.format(out, fmt, fmt + char_traits<charT>::length(fmt), flags)
Original:
same as 1), but the formatted replacement is performed as if by calling m.format(out, fmt, fmt + char_traits<charT>::length(fmt), flags)
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
3-4)
Construye una cadena vacía result de std::basic_string<CharT, ST, SA> tipo y llama std::regex_replace(std::back_inserter(result), s.begin(), s.end(), e, fmt, flags) .
Original:
Constructs an empty string 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).
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
5-6)
Construye una cadena vacía result de std::basic_string<CharT> tipo y llama std::regex_replace(std::back_inserter(result), s, s + std::char_traits<CharT>::length(s), e, fmt, flags) .
Original:
Constructs an empty string 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).
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.

Contenido

[editar] Parámetros

first, last -
la secuencia de caracteres de entrada, representada como un 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 -
la secuencia de caracteres de entrada, representada como std :: basic_string o 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 -
el std :: basic_regex que se comparará con el 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 -
las banderas del partido 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 -
la sustitución de expresiones regulares cadena de formato, sintaxis exacta depende del 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 -
iterador de salida para almacenar el resultado de la sustitución
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

1-2)
Devuelve una copia del iterador salida out .
Original:
Returns a copy of the output iterator out.
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
3-6)
Devuelve el result cadena que contiene la salida .
Original:
Returns the string result which contains the output.
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.

[editar] Excepciones

Puede lanzar std::regex_error para indicar una situación de error .
Original:
May throw std::regex_error to indicate an situación de error.
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.

[editar] Ejemplo

#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';
}

Output:

Q[u][i]ck br[o]wn f[o]x

[editar] Ver también

intentos para que coincida con una expresión regular para cualquier parte de la secuencia 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.

(función de plantilla) [edit]
opciones específicas de juego
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) [edit]