#include <iostream>
#include <regex>
#include <string>
// b[aeou]y: This pattern looks for strings that match the following:
// b: The letter "b".
// [aeou]: Any single character that is either "a", "e", "o", or "u".
// y: The letter "y".
void checkPattern(const std::string& pattern, const std::string& text) {
std::regex re(pattern);
bool match = std::regex_search(text, re);
std::cout << (match ? "true" : "false") << std::endl;
}
int main() {
const std::string pattern = "b[aeou]y";
checkPattern(pattern, "A smart boy"); // b o y
checkPattern(pattern, "I want to buy this laptop"); // b u y
checkPattern(pattern, "baay");
checkPattern(pattern, "baeouy");
checkPattern(pattern, "baey");
checkPattern(pattern, "This is beauty");
checkPattern(pattern, "A programming book");
}
/*
run:
true
true
false
false
false
false
false
*/