17.24
#include <iostream>
#include <regex>
using namespace std;
int main()
{
string phone =
"(\\()?(\\d{3})(\\))?([-. ])?(\\d{3})([-. ])?(\\d{4})";
regex r(phone);
smatch m;
string s;
string fmt = "$2.$5.$7";
while (getline(cin, s))
cout << regex_replace(s, r, fmt) << endl;
return 0;
}
17.25
#include <iostream>
#include <regex>
#include <vector>
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)) {
s = regex_replace(s, r, fmt);
sregex_iterator it(s.begin(), s.end(), r);
cout << it->str() << endl;
}
return 0;
}
17.26
#inclu