| Localization library | |||||||||||||||||||||||||
| Regular expressions library(C++11) | |||||||||||||||||||||||||
| Formatting library(C++20) | |||||||||||||||||||||||||
| Null-terminated sequence utilities | |||||||||||||||||||||||||
| Byte strings | |||||||||||||||||||||||||
| Multibyte strings | |||||||||||||||||||||||||
| Wide strings | |||||||||||||||||||||||||
| Primitive numeric conversions | |||||||||||||||||||||||||
| |||||||||||||||||||||||||
| Text encoding identifications | |||||||||||||||||||||||||
| |||||||||||||||||||||||||
| 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) |
| 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> std::basic_ostream<CharT,Traits>& | (since C++11) | |
Writes the representation of the matched subsequencem to the output streamos. Equivalent toos<< m.str().
| os | - | output stream to write the representation to |
| m | - | a sub-match object to output |
os
#include <iostream>#include <regex>#include <string> int main(){std::string sentence{"Quick red fox jumped over a lazy hare."};conststd::regex re{"([A-z]+) ([a-z]+) ([a-z]+)"};std::smatch words;std::regex_search(sentence, words, re);for(constauto& 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]