The match_results size() is a inbuilt function in C++ which returns the number of matches ans sub-matches in the match_result object.
smatch_name.size() Note: smatch_name is an object of match_results class.
Parameters: The function accept no parameters.
Return vaulue: It returns the number of matches in the match_result object.
Note: First element always contains the whole regex match while the others conatain the particular Capturing Group
Below programs illustrate the above function.
match size is 3
match size is 3 match 0 has a length of 13 match 1 has a length of 5 match 2 has a length of 8
Don’t stop now and take your learning to the next level. Learn all the important concepts of Data Structures and Algorithms with the help of the most trusted course: DSA Self Paced. Become industry ready at a student-friendly price.
- map::size() in C++ STL
- set::size() in C++ STL
- array::size() in C++ STL
- unordered_multiset size() in C++ STL
- unordered_map size() in C++ STL
- bitset size() in C++ STL
- list size() function in C++ STL
- multimap size() function in C++ STL
- unordered_multimap size() function in C++ STL
- Why is the size of an empty class not zero in C++?
- valarray size() function in C++
- multiset size() in C++ STL with Examples
- unordered_set size() function in C++ STL
- How to find size of array in C/C++ without using sizeof ?
- How to print size of array parameter in C++?
- How to quickly swap two arrays of same size in C++?
- Size of array after repeated deletion of LIS
- C Program to find size of a File
- 2D vector in C++ with user defined size
- Maximum product of an increasing subsequence of size 3
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.