std::basic_regex<CharT,Traits>::mark_count (3) - Linux Manuals
std::basic_regex<CharT,Traits>::mark_count: std::basic_regex<CharT,Traits>::mark_count
Command to display std::basic_regex<CharT,Traits>::mark_count
manual in Linux: $ man 3 std::basic_regex<CharT,Traits>::mark_count
NAME
std::basic_regex<CharT,Traits>::mark_count - std::basic_regex<CharT,Traits>::mark_count
Synopsis
unsigned mark_count() const; (since C++11)
Returns the number of marked sub-expressions (also known as capture groups) within the regular expression.
Parameters
(none)
Return value
The number of marked sub-expressions within the regular expression.
Exceptions
(none)
Example
// Run this code
#include <iostream>
#include <regex>
int main()
{
std::regex r1{"abcde"};
std::cout << "r1 has " << r1.mark_count() << " subexpressions" << '\n';
// Expected: 0
std::regex r2{"ab(c)de"};
std::cout << "r2 has " << r2.mark_count() << " subexpressions" << '\n';
// Expected: 1
std::regex r3{"a(bc)d(e)"};
std::cout << "r3 has " << r3.mark_count() << " subexpressions" << '\n';
// Expected: 2
// nested sub-expressions
std::regex r4{"abc(de(fg))"};
std::cout << "r4 has " << r4.mark_count() << " subexpressions" << '\n';
// Expected: 2
// escaped parentheses
std::regex r5{"a(bc\\(\\)de)"};
std::cout << "r5 has " << r5.mark_count() << " subexpressions" << '\n';
// Expected: 1
// using nosubs flag
std::regex r6 {"ab(c)de", std::regex_constants::nosubs};
std::cout << "r6 has " << r6.mark_count() << " subexpressions" << '\n';
// Expected: 0
}
Output:
r1 has 0 subexpressions
r2 has 1 subexpressions
r3 has 2 subexpressions
r4 has 2 subexpressions
r5 has 1 subexpressions
r6 has 0 subexpressions
Pages related to std::basic_regex<CharT,Traits>::mark_count
- std::basic_regex<CharT,Traits>::assign (3) - std::basic_regex<CharT,Traits>::assign
- std::basic_regex<CharT,Traits>::basic_regex (3) - std::basic_regex<CharT,Traits>::basic_regex
- std::basic_regex<CharT,Traits>::flags (3) - std::basic_regex<CharT,Traits>::flags
- std::basic_regex<CharT,Traits>::getloc (3) - std::basic_regex<CharT,Traits>::getloc
- std::basic_regex<CharT,Traits>::imbue (3) - std::basic_regex<CharT,Traits>::imbue
- std::basic_regex<CharT,Traits>::operator= (3) - std::basic_regex<CharT,Traits>::operator=
- std::basic_regex<CharT,Traits>::swap (3) - std::basic_regex<CharT,Traits>::swap
- std::basic_regex<CharT,Traits>::~basic_regex (3) - std::basic_regex<CharT,Traits>::~basic_regex
- std::basic_regex (3) - std::basic_regex
- std::basic_regexconstants (3) - std::basic_regexconstants
- std::basic_filebuf (3) - std::basic_filebuf
- std::basic_filebuf<CharT,Traits>::basic_filebuf (3) - std::basic_filebuf<CharT,Traits>::basic_filebuf
- std::basic_filebuf<CharT,Traits>::close (3) - std::basic_filebuf<CharT,Traits>::close
- std::basic_filebuf<CharT,Traits>::imbue (3) - std::basic_filebuf<CharT,Traits>::imbue
- std::basic_filebuf<CharT,Traits>::is_open (3) - std::basic_filebuf<CharT,Traits>::is_open