std::match_results<BidirIt,Alloc>::str
Min standard notice:
Returns a string representing the indicated sub-match.
# Declarations
string_type str( size_type n = 0 ) const;
(since C++11)
# Parameters
n: integral number specifying which match to return
# Return value
Returns a string representing the specified match or sub match.
# Example
#include <iostream>
#include <regex>
#include <string>
int main()
{
std::string target("baaaby");
std::smatch sm;
std::regex re1("a(a)*b");
std::regex_search(target, sm, re1);
std::cout << "entire match: " << sm.str(0) << '\n'
<< "submatch #1: " << sm.str(1) << '\n';
std::regex re2("a(a*)b");
std::regex_search(target, sm, re2);
std::cout << "entire match: " << sm.str(0) << '\n'
<< "submatch #1: " << sm.str(1) << '\n';
}