std::match_...s::position(3)
bestie, you found the std::match_...s::position(3) page from the C++ Standard Libary, and honestly it's giving βtiny but important regex detailβ energy π
. The manual name is folded in right here so the header line doesn't have to be copy-pasted β we're doing cute formatting, not boring formatting.
β¨ NAME β¨
std::match_results::position - std::match_results::position
Yes, the NAME section is literally the function naming itself. Iconic, lowkey self-obsessed, but valid π.
π¦ Synopsis π¦
difference_type position( size_type n = 0 ) const; (since C++11)
It returns the position of the first character of the specified sub-match. Here's the breakdown, bestie:
- If
n == 0, the position of the first character of the entire matched expression is returned. - If
n > 0 && n < size(), the position of the first character of thenth sub-match is returned. - If
n >= size(), a position of the first character of the unmatched match is returned.
π Parameters π
nβ integral number specifying which match to examine.
π Return value π
The position of the first character of the specified match or sub-match. That's it. That's the tea ββ¨.
π Example π
// Run this code
#include <iostream>
#include <regex>
#include <string>
int main()
{
std::regex re("a(a)*b");
std::string target("aaab");
std::smatch sm;
std::regex_match(target, sm, re);
std::cout << sm.position(1) << '\n';
}
β Output: β
2
π See also π
operator[]β returns specified sub-match (public member function).
okay so the cute sign-off: source http://cppreference.com, version/date stamp 2024.06.10, footer title std::match_...s::position(3) β signed off with sparkles and zero boring manpage energy π§π
π¦ where this page comes from
- nixpkgs unstable: stdman 2024.07.05
- opensuse-leap 16.0: stdman 2024.07.05-bp160.1.9 Β· MIT
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash-1017 on : a language model's rewrite of the original, under its terms