The match_results::operator= is used to replace all the matches in a smatch object with new matches from another smatch object.
smatch_name1 = (smatch_name2) Note: smatch_name is an object of match_results class.
Parameters: The smatch object on the right side gets copied to the one at the left side.
Return Value: It does not return anything.
Note: First element always contains the whole regex match while the others conatain the particular Capturing Group.
Below programs illustrate the above function.
Matches are: Geeksforgeeks Geeks forgeeks
Smatch with maximum matches: Geeksforgeeks Ge eks forgeeks
- Why overriding both the global new operator and the class-specific operator is not ambiguous?
- new vs operator new in C++
- map operator= in C++ STL
- set operator= in C++ STL
- map::operator in C++ STL
- dot (.) operator in C/C++
- match_results operator in C++ STL
- bitset operator in C++ STL
- unordered_multimap operator= in C++
- multimap operator = in C++ STL
- deque::operator= and deque::operator in C++ STL
- multiset::operator= in C++ STL
- multimap::operator= in C++ STL
- array::operator[ ] in C++ STL
- list::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 firstname.lastname@example.org. 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.