std::match_results<BidirIt,Alloc>::size

Returns the number of submatches, i.e. std::distance(begin(), end()).

# Declarations

size_type size() const noexcept;

(since C++11)

# Return value

The number of submatches.

# Example

#include <iostream>
#include <regex>
#include <string>
 
int main()
{
    std::regex re("a(a)*b");
    std::string target("aaab");
    std::smatch sm;
 
    std::cout << sm.size() << '\n';
 
    std::regex_match(target, sm, re);
    std::cout << sm.size() << '\n';
}

# See also