operator<<(std::sub_match)
From cppreference.com
C++
Feature test macros (C++20)
Concepts library (C++20)
Metaprogramming library (C++11)
Ranges library (C++20)
Filesystem library (C++17)
Concurrency support library (C++11)
Execution control library (C++26)
Text processing library
Regular expressions library (C++11)
Formatting library (C++20)
(C++17)
(C++17)
(C++17)
(C++17)
(C++17)
(C++26)
Regular expressions library
Classes
(C++11)
(C++11)
(C++11)
Algorithms
(C++11)
(C++11)
(C++11)
Iterators
(C++11)
(C++11)
Exceptions
(C++11)
Traits
(C++11)
Constants
(C++11)
(C++11)
(C++11)
Regex Grammar
(C++11)
std::sub_match
Member functions
Non-member functions
(until C++20)(until C++20)(until C++20)(until C++20)(until C++20)(C++20)
operator<<
template< class CharT, class Traits, class BidirIt >
(since C++11)
std::basic_ostream <CharT,Traits>&
Writes the representation of the matched subsequence m to the output stream os. Equivalent to os << m.str().
[edit] Parameters
os
-
output stream to write the representation to
m
-
a sub-match object to output
[edit] Return value
os
[edit] Example
Run this code
#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'; }
Output:
[Quick red fox] [Quick] [red] [fox]