The Search Result

Whenever we verify whether 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 a std::regex_match or std::regex_search. std::match_results is a sequential container having at least one capture group of a std::sub_match object. The std::sub_match objects are sequences of characters.

ℹ️ What is a capture group?
Capture groups allow it to further analyse the search result in 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 1000+ tech skills courses.