| 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 | ||||
sub_match::strsub_match::operator string_type | ||||
| Non-member functions | ||||
(until C++20)(until C++20)(until C++20)(until C++20)(until C++20)(C++20) | ||||
operator string_type()const; | (1) | |
string_type str()const; | (2) | |
Converts to an object of the underlyingstd::basic_string type.
The matched character sequence as an object of the underlyingstd::basic_string type. If thematched member isfalse, then returns the empty string.
Linear in the length of the underlying character sequence.
#include <cassert>#include <iostream>#include <regex>#include <string> int main(){conststd::string html{R"("<a href="https://cppreference.com/">)"}; const std::regex re{"(http|https|ftp)://([a-z]+)\\.([a-z]{3})"};std::smatch parts;std::regex_search(html, parts, re);for(std::ssub_matchconst& sub: parts){conststd::string s= sub;// (1) implicit conversionassert(s== sub.str());// (2)std::cout<< s<<'\n';}}
Output:
https://cppreference.comhttpscppreferencecom