operator<< (std::sub_match)
|
template
<
class
CharT,
class
Traits,
class
BidirIt
>
std::
basic_ostream
<
CharT,Traits
>
&
|
(C++11以降) | |
一致した部分シーケンス m の表現を出力ストリーム os に書き込みます。 以下と等価です: os << m. str ( ) 。
パラメータ
| os | - | 表現を書き込む出力ストリーム |
| m | - | 出力するサブマッチオブジェクト |
戻り値
os
例
#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'; }
出力:
[Quick red fox] [Quick] [red] [fox]