#include <iostream> #include <regex> #include <string> int main() { std::string text = "Contact me at example@example.com"; std::regex email_regex("[a-zA-Z0-9._%+-]+@[a-zA-Z0-9.-]+\\.[a-zA-Z]{2,}"); std::smatch match; if (std::regex_search(text, match, email_regex)) { std::cout << "Found email: " << match.str() << std::endl; } else { std::cout << "No email found!" << std::endl; } return 0; }