#include <iostream> #include <regex> #include <string> int main() { std::string text = "My old number was 123-456-7890, but my new number is 987-654-3210."; std::regex phone_regex("\\d{3}-\\d{3}-\\d{4}"); std::string result = std::regex_replace(text, phone_regex, "XXX-XXX-XXXX"); std::cout << result << std::endl; return 0; }