std::match_results::suffix(3)

πŸ“¦ version 2024.07.05, in nixpkgs unstable, opensuse-leap 16.0

Welcome to std::match_results::suffix(3), bestie β€” a page from the C++ Standard Libary (yes, β€œLibary” is exactly how it’s spelled here, and we don’t edit icons πŸ’…). This one is all about the unmatched suffix, and it’s lowkey iconic.

πŸŽ€ NAME πŸŽ€

std::match_results::suffix β€” std::match_results::suffix. Self-titled debut album energy, honestly. πŸ’Ώ

✨ SYNOPSIS ✨

const_reference suffix() const;

(since C++11) β€” this has been the vibe since C++11, periodt.

Okay so what does it actually do? It obtains a reference to the std::sub_match object representing the target sequence between the end of the entire match of the regular expression and the end of the target sequence. It’s giving β€œthe leftover tail after the full regex match, all the way to the end of the target sequence” energy. πŸ¦‹

🚨 Undefined behavior alert: The behavior is undefined unless ready() is true. Not β€œprobably fine” β€” undefined. Check ready() first, bestie. No cap. 😭

πŸ¦‹ PARAMETERS πŸ¦‹

(none) β€” literally none. No parameters, no drama. 🫢

πŸ‘‘ RETURN VALUE πŸ‘‘

Reference to the unmatched suffix. That’s the return value: Reference to the unmatched suffix. Clean, simple, main character energy. πŸ’…

🌸 EXAMPLE 🌸

// Run this code β€” go on, run it:

#include <iostream>
#include <regex>
#include <string>

int main()
{
    std::regex re("a(a)*by");
    std::string target("baaaby123");
    std::smatch sm;

    std::regex_search(target, sm, re);
    std::cout << sm.suffix() << '\n';
}

πŸ“ OUTPUT πŸ“

123

Slay. The suffix is 123, and it ate. πŸ”₯

πŸ’œ SEE ALSO πŸ’œ

  • Returns the sub-sequence between the beginning of the target sequence and the prefix beginning of the full match β€” and yep, it’s a public member function. The see-also bestie is doing its thing. πŸ¦‹

Mwah πŸ’‹ β€” source: http://cppreference.com; date/version: 2024.06.10; page: std::match_results::suffix(3). That’s the whole footer, bestie β€” we’re done here. 🌈

πŸ“¦ where this page comes from