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

using namespace std;

int main() {
    string phone = "(\\()?(\\d{3})(\\))?([-. ])?(\\d{3})([-. ])?(\\d{4})";
    regex r(phone);
    string s;
    string fmt = "$2.$5.$7";
    while(getline(cin, s)) {
        cout << regex_replace(s, r, fmt) << endl;
    }
    return 0;
}

Add solution for chapter 17 test 24
Add solution for chapter 17 test 24