std::match_results::suffix(3)
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 unlessready()is true. Not βprobably fineβ β undefined. Checkready()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
- 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