Modernes C++ programmieren

Okt 23, 2024

lst-0906-godb.cpp

//#(compile) c++; compiler:g132; options:-O3 -std=c++23; libs:-
// https://godbolt.org/z/E9hcWGMW4 
#include <regex>
#include <string>
#include <iostream>
using std::regex; using std::regex_match; using std::regex_search;
int main() {
    std::cout << std::boolalpha;
    regex muster {"ello"};
    std::string text = "Hello world";
    auto b1 = regex_match (text.cbegin(), text.cend(), muster); // passt nicht
    std::cout << b1 << "\n"; // Ausgabe: false
    auto b2 = regex_search(text.cbegin(), text.cend(), muster); // gefunden
    std::cout << b2 << "\n"; // Ausgabe: true
}