std::match_results::prefix(3)

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

πŸ’… std::match_results::prefix β€” a C++ Standard Libary moment πŸ’…

πŸ’– NAME πŸ’–

std::match_results::prefix β€” std::match_results::prefix. That's the name, bestie, no notes ✨

✨ Synopsis ✨

const_reference prefix() const;  (since C++11)

Obtains a reference to the std::sub_match object representing the target sequence between the start of the beginning of the target sequence and the start of the entire match of the regular expression. Slay.

⚠️ warning: the behavior is undefined unless ready() == true. That means it's UB territory if ready() == true is not true β€” and UB is not the vibe, bestie 😭

πŸŽ€ Parameters πŸŽ€

(none) β€” literally zero parameters, we love a low-maintenance icon 🫢

🌟 Return value 🌟

Reference to the unmatched prefix. Periodt πŸ’…

🌸 Example 🌸

Run this code:

// Run this code

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

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

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

⭐ Output ⭐

b

πŸ‘€ See also πŸ‘€

  • returns sub-sequence between the end of the full match and the end of the suffix target sequence (public member function) β€” yes bestie, that's the other one πŸ‘‘

byeee 🫢 source: http://cppreference.com; version/date: 2024.06.10; page: std::match_results::prefix(3). mwah πŸ’‹

πŸ“¦ where this page comes from