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. |
definiert in Header <regex>
|
||
template< class OutputIt, class BidirIt, class Traits, class CharT, |
(1) | (seit C++11) |
template< class OutputIt, class BidirIt, class Traits, class CharT > |
(2) | (seit C++11) |
template< class Traits, class CharT, class STraits, class SAlloc, |
(3) | (seit C++11) |
template< class Traits, class CharT, class STraits, class SAlloc > |
(4) | (seit C++11) |
template< class Traits, class CharT, class STraits, class SAlloc > |
(5) | (seit C++11) |
template< class Traits, class CharT > std::basic_string<CharT> |
(6) | (seit C++11) |
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
.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
wie er ist .out
as-is.You can help to correct and verify the translation. Click here for instructions.
flags
enthält std::regex_constants::format_no_copy, werden die nicht-passenden Teilfolgen nicht in out
kopiert .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
std::regex_constants::format_first_only enthält, wird nur die erste Übereinstimmung ersetzt .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
vom Typ std::basic_string<CharT, ST, SA> und ruft 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
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) .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.
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
out
.out
.You can help to correct and verify the translation. Click here for instructions.
result
die Ausgabe enthält .result
which contains the output.You can help to correct and verify the translation. Click here for instructions.
[Bearbeiten] Ausnahmen
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
(C++11) |
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) |
(C++11) |
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) |