The Search Result

Whenever we verify if a piece of text satisfies our regular expression, we have to store the results somewhere. std::match_results allows us to do just that.

We'll cover the following

The object of type std::match_results is the result of an std::regex_match or std::regex_search. std::match_results is a sequential container having at least one capture group of an std::sub_match object. The std::sub_match objects are sequences of characters.

ℹ️ What is a capture group?
Capture groups allow us to further analyse the search results of a regular expression. They are defined by a pair of parentheses (). The regular expression ((a+)(b+)(c+)) has four capture groups: ((a+)(b+)(c+)), (a+), (b+), and (c+). The total result is the 0th capture group.

C++ has four types of synonyms of type std::match_results:

Get hands-on with 1400+ tech skills courses.