Namensräume
Varianten
Aktionen

std::regex_replace

Aus cppreference.com
< cpp‎ | regex

 
 
Reguläre Ausdrücke Bibliothek
Classes
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)
Algorithmen
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)
Iteratoren
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)
Ausnahmen
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)
Traits
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)
Konstanten
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) (seit 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) (seit 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) (seit 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) (seit 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) (seit 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) (seit C++11)
1)
Erzeugt ein std::regex_iterator Objekt i wie von std::regex_iterator<BidirIt, CharT, traits> i(first, last, e, flags), und nutzt sie, um durch jedes Spiel des e innerhalb der Sequenz [first,last) fort. Für jeden solchen Spiel m, kopiert den nicht angepassten Teilfolge (m.prefix()) in out wie er ist und ersetzt dann den übereinstimmenden Teilfolge mit der formatierten Ersetzungsstring, als ob durch den Aufruf m.format(out, fmt, flags). Wenn keine weiteren Übereinstimmungen gefunden werden, kopiert die verbleibenden nicht-passenden Zeichen 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.
Wenn es keine Übereinstimmungen gibt, wird die gesamte Sequenz in out wie er ist .
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.
Wenn flags enthält std::regex_constants::format_no_copy, werden die nicht-passenden Teilfolgen nicht in out kopiert .
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.
Wenn flags std::regex_constants::format_first_only enthält, wird nur die erste Übereinstimmung ersetzt .
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)
Gleiche wie 1), aber der formatierten Ersatz wird wie durch Aufrufen m.format(out, fmt, fmt + char_traits<charT>::length(fmt), flags) durchgeführt
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)
Erzeugt einen leeren String result vom Typ std::basic_string<CharT, ST, SA> und ruft 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)
Erzeugt einen leeren String result vom Typ std::basic_string<CharT> und ruft 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.

Inhaltsverzeichnis

[Bearbeiten] Parameter

first, last -
das Eingangszeichen Sequenz, als ein Paar von Iteratoren dargestellt
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 -
das eingegebene Zeichen-Sequenz, wie std :: basic_string oder Zeichenarray vertreten
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 -
die std :: basic_regex, die gegen die Eingabesequenz abgestimmt werden
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 -
die Match-Flags des Typs std::regex_constants::match_flag_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 -
die regex Ersatz Format-String, hängt genaue Syntax auf den Wert der 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 -
Ausgabeiterator um das Ergebnis der Ersetzung speichern
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.

[Bearbeiten] Rückgabewert

1-2)
Gibt eine Kopie des Ausgabeiterator 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)
Gibt die Zeichenfolge result die Ausgabe enthält .
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.

[Bearbeiten] Ausnahmen

Kann std::regex_error werfen, um eine Fehler geben .
Original:
May throw std::regex_error to indicate an Fehler.
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.

[Bearbeiten] Beispiel

#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

[Bearbeiten] Siehe auch

Versuche, einen regulären Ausdruck zu jedem Teil der Zeichenfolge entsprechen
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.

(Funktions-Template) [edit]
spezifische Optionen, um passende
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]