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]