The match_results::operator is a built function in C++ which used to get the i-th match in the match_result object. It gives the reference to the match at the position given inside the operator.
smatch_name[N] Note: smatch_name is an object of match_results class.
Parameters: It accepts a single parameter N which specifies the Match number. It is lower than match_results::size. The match number 0 represents the entire matched expression. Subsequent match numbers identify the sub-expressions if any. The passed integral is an unsigned integral type.
Return value: It returns the direct reference to the match at the N-th match.
Note: First element always contains the whole regex match while the others conatain the particular Capturing Group.
Below programs illustrates the above function.
Matches are: match 0 is Geeksforgeeks match 1 is Geeks match 2 is forgeeks
max-length sub match is forgeeks with a length of 8
Attention reader! Don’t stop learning now. Get hold of all the important DSA concepts with the DSA Self Paced Course at a student-friendly price and become industry ready.
- vector::operator= and vector::operator[ ] in C++ STL
- deque::operator= and deque::operator in C++ STL
- Why overriding both the global new operator and the class-specific operator is not ambiguous?
- Operator Overloading '<<' and '>>' operator in a linked list class
- array::operator[ ] in C++ STL
- list::operator= in C++ STL
- forward_list::operator= in C++ STL
- map::operator in C++ STL
- multiset::operator= in C++ STL
- multimap::operator= in C++ STL
- unordered_map operator= in C++ STL
- unordered_multiset operator = in C++ STL
- bitset operator in C++ STL
- multimap operator = in C++ STL
- map operator= in C++ STL
- unordered_set operator= in C++ STL
- set operator= in C++ STL
- unordered_set operator!= in C++ STL
- unordered_set == operator in C++ STL
- unordered_map operator in C++ STL
If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to email@example.com. See your article appearing on the GeeksforGeeks main page and help other Geeks.
Please Improve this article if you find anything incorrect by clicking on the "Improve Article" button below.