operator<< (std::sub_match)
|
template
<
class
CharT,
class
Traits,
class
BidirIt
>
std::
basic_ostream
<
CharT,Traits
>
&
|
(seit C++11) | |
Schreibt die Darstellung der übereinstimmenden Teilsequenz m in den Ausgabestream os . Äquivalent zu os << m. str ( ) .
Parameter
| os | - | Ausgabestream, in den die Darstellung geschrieben wird |
| m | - | ein Sub-Match-Objekt zur Ausgabe |
Rückgabewert
os
Beispiel
#include <iostream> #include <regex> #include <string> int main() { std::string sentence{"Quick red fox jumped over a lazy hare."}; const std::regex re{"([A-z]+) ([a-z]+) ([a-z]+)"}; std::smatch words; std::regex_search(sentence, words, re); for (const auto& m : words) // m has type `const std::sub_match<std::string::const_iterator>&` std::cout << '[' << m << "] "; std::cout << '\n'; }
Ausgabe:
[Quick red fox] [Quick] [red] [fox]