Namespace
Varianti

std::regex_replace

Da cppreference.com.
< cpp‎ | regex

 
 
Espressioni regolari libreria
Classi
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)
Algoritmi
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)
Iteratori
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)
Eccezioni
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)
Tratti
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)
Costanti
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)
 
Elemento definito nell'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) (dal 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) (dal 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) (dal 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) (dal 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) (dal 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) (dal C++11)
1)
Costruisce un oggetto std::regex_iterator i come per std::regex_iterator<BidirIt, CharT, traits> i(first, last, e, flags), e lo usa per scorrere tutte le partite del e all'interno del [first,last) sequenza. Per ogni partita m tale, copia il non appaiato sottosequenza (m.prefix()) in out così come sono e quindi sostituisce il sottosequenza abbinato con la stringa di sostituzione formattata come se chiamando m.format(out, fmt, flags). Quando non vengono reperite altre corrispondenze, copia i restanti non corrispondenza caratteri 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.
Se non ci sono partite, copia l'intera sequenza in out così come sono.
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.
Se flags contiene std::regex_constants::format_no_copy, i non-corrispondenza sottosequenze non vengono copiate nel 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.
Se flags contiene std::regex_constants::format_first_only, solo la prima corrispondenza è sostituito.
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)
come 1), ma la sostituzione formattato viene eseguita come se chiamando 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)
Costruisce un result stringa vuota di std::basic_string<CharT, ST, SA> tipo e chiama 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)
Costruisce un result stringa vuota di std::basic_string<CharT> tipo e chiama 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.

Indice

[modifica] Parametri

first, last -
il carattere sequenza di input, rappresentato da una coppia di iteratori
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 -
il carattere di sequenza di input, rappresentato come std :: basic_string o array di caratteri
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 -
std :: basic_regex che verrà confrontata con la sequenza di input
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 -
le bandiere di incontro 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 stringa di sostituzione regex formato, sintassi esatta dipende dal valore di 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 -
uscita iteratore per memorizzare il risultato della sostituzione
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.

[modifica] Valore di ritorno

1-2)
Restituisce una copia del iteratore di uscita 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)
Restituisce la result stringa che contiene l'output.
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.

[modifica] Eccezioni

Può lanciare std::regex_error per indicare un condizione di errore.
Original:
May throw std::regex_error to indicate an condizione di errore.
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.

[modifica] Esempio

#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

[modifica] Vedi anche

tentativi di corrispondono a un'espressione regolare a qualsiasi parte la sequenza di caratteri
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.

(funzione di modello) [modifica]
soluzioni specifiche per corrispondenza
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) [modifica]